Description
Ammar Husain opened SPR-16318 and commented
For a vanilla REST endpoint created in Spring Boot (1.5.9 Release) as below
@RequestMapping(value = "/foo", method = RequestMethod.GET, produces = "text/csv")
public String getCsv() {
throw new IllegalArgumentException();
}
if request has header Accept: application/json,text/csv it should respond with the JSON representation of error / HTTP 500, instead it gives HTTP 406 - Not Acceptable.
Thus Spring seems not to respect the Accept header as it has following exception in DEBUG logs -> org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
Even after adding additional message converters (StringMessageConverter) the error persists.
Moreover configuring the @RestControllerAdvice
has no effect.
Affects: 4.3.13
Reference URL: https://stackoverflow.com/questions/47831530/406-when-exception-thrown-in-spring-controller-with-accept-header-of-text-csv
Issue Links:
- @RequestMapping get 406 Not Acceptable when I use MediaType.IMAGE_PNG_VALUE [SPR-17205] #21738
@RequestMapping
get 406 Not Acceptable when I use MediaType.IMAGE_PNG_VALUE ("is duplicated by") - Content negotiation fails with the conjonction of text/plain and ExceptionHandler [SPR-14411] #18982 Content negotiation fails with the conjonction of text/plain and ExceptionHandler ("is duplicated by")
- Content negotiation fails with the conjonction of text/plain and ExceptionHandler [SPR-14411] #18982 Content negotiation fails with the conjonction of text/plain and ExceptionHandler
- Content-Type not set correctly on @ControllerAdvice [SPR-17394] #21927 Content-Type not set correctly on
@ControllerAdvice
Referenced from: commits 395792b
0 votes, 7 watchers