Return 500 if producible attribute present
When a request is mapped through a producible condition on an @RequestMapping, then a failure to find a converter/decoder should be a 500 because the return type + media type pair were declared by the controller and that should be possible to render. Closes gh-23287
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -309,7 +309,11 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
||||
}
|
||||
|
||||
if (body != null) {
|
||||
if (isContentTypePreset) {
|
||||
Set<MediaType> producibleMediaTypes =
|
||||
(Set<MediaType>) inputMessage.getServletRequest()
|
||||
.getAttribute(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE);
|
||||
|
||||
if (isContentTypePreset || !CollectionUtils.isEmpty(producibleMediaTypes)) {
|
||||
throw new HttpMessageNotWritableException(
|
||||
"No converter for [" + valueType + "] with preset Content-Type '" + contentType + "'");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user