Polish
This commit is contained in:
@@ -31,7 +31,7 @@ public class UnsupportedMediaTypeStatusException extends ResponseStatusException
|
|||||||
|
|
||||||
private final MediaType contentType;
|
private final MediaType contentType;
|
||||||
|
|
||||||
private final List<MediaType> supportedContentTypes;
|
private final List<MediaType> supportedMediaTypes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,16 +40,16 @@ public class UnsupportedMediaTypeStatusException extends ResponseStatusException
|
|||||||
public UnsupportedMediaTypeStatusException(String reason) {
|
public UnsupportedMediaTypeStatusException(String reason) {
|
||||||
super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, reason);
|
super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, reason);
|
||||||
this.contentType = null;
|
this.contentType = null;
|
||||||
this.supportedContentTypes = Collections.emptyList();
|
this.supportedMediaTypes = Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for when the Content-Type can be parsed but is not supported.
|
* Constructor for when the Content-Type can be parsed but is not supported.
|
||||||
*/
|
*/
|
||||||
public UnsupportedMediaTypeStatusException(MediaType contentType, List<MediaType> supportedContentTypes) {
|
public UnsupportedMediaTypeStatusException(MediaType contentType, List<MediaType> supportedMediaTypes) {
|
||||||
super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, "Content type '" + contentType + "' not supported");
|
super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, "Content type '" + contentType + "' not supported");
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
this.supportedContentTypes = Collections.unmodifiableList(supportedContentTypes);
|
this.supportedMediaTypes = Collections.unmodifiableList(supportedMediaTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -64,8 +64,8 @@ public class UnsupportedMediaTypeStatusException extends ResponseStatusException
|
|||||||
* Return the list of supported content types in cases when the Content-Type
|
* Return the list of supported content types in cases when the Content-Type
|
||||||
* header is parsed but not supported, or an empty list otherwise.
|
* header is parsed but not supported, or an empty list otherwise.
|
||||||
*/
|
*/
|
||||||
public List<MediaType> getSupportedContentTypes() {
|
public List<MediaType> getSupportedMediaTypes() {
|
||||||
return this.supportedContentTypes;
|
return this.supportedMediaTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ public class RequestMappingInfoHandlerMappingTests {
|
|||||||
assertError(mono, UnsupportedMediaTypeStatusException.class, ex ->
|
assertError(mono, UnsupportedMediaTypeStatusException.class, ex ->
|
||||||
assertEquals("Invalid supported consumable media types",
|
assertEquals("Invalid supported consumable media types",
|
||||||
Collections.singletonList(new MediaType("application", "xml")),
|
Collections.singletonList(new MediaType("application", "xml")),
|
||||||
ex.getSupportedContentTypes()));
|
ex.getSupportedMediaTypes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testHttpOptions(String requestURI, String allowHeader) throws Exception {
|
private void testHttpOptions(String requestURI, String allowHeader) throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user