-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Andrew Ebaugh opened SPR-6214 and commented
AnnotationMethodHandlerAdapter will throw a HttpMediaTypeNotAcceptableException in cases where the registered message converts should be able to support an acceptable representation.
It looks like the problem is in the following method: AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.handleResponseBody(...)
The inner-most part of the loop is only successful on this condition:
if (supportedMediaType.includes(acceptedMediaType)) {
If the acceptedMediaType is a wildcard, the condition fails. It seems it should rather be the revers:
if (acceptedMediaType.includes(supportedMediaType)) {
Then the fact that acceptedMediaType is a wildcard will make it potentially match what is supported.
The impact is that most client use a wildcard when Accept header is not explicitly set, and this results in a failure.
Will attach test.
Affects: 3.0 RC1
Attachments:
- ResponseBodyExceptionTest.java (4.34 kB)
Issue Links:
- @ResponseBody throws HttpMediaTypeNotAcceptableException if client accepts "*/*" [SPR-6686] #11352
@ResponseBodythrows HttpMediaTypeNotAcceptableException if client accepts "/" - AbstractHttpMessageConverter canWrite logic the wrong way round?? [SPR-6970] #11635 AbstractHttpMessageConverter canWrite logic the wrong way round??
Referenced from: commits 5310035