Brian Clozel opened SPR-13176 and commented
#17376 introduced the ability for a RequestBodyAdvice to turn empty input into some default value by iterating over all converters even when the body is empty. In some cases existing code that implicitly relies on the previous behavior (i.e. not looping over converters when the body is empty) may be affected.
For example consider the following from the referenced Boot ticket:
@RequestMapping(value = "/test", method = [RequestMethod.GET, RequestMethod.POST])
public Person test(@RequestBody(required = false) Person person) {
//...
}
The above is arguably not ideal way to declare request mappings since GET requests should not have a body and they don't typically have a content-type (the required=false attribute is somewhat used as a workaround instead of creating a separate handler method for GET requests). In this scenario, previously Spring MVC would exit early due to the null body + required=false. Currently however it loops over converters, it picks application/octet-stream by default, and since no converter can handle that, it results in an HttpMediaTypeNotSupportedException.
Affects: 4.2 RC1
Reference URL: spring-projects/spring-boot#3313
Issue Links:
Referenced from: commits 3272a3b, 244c95b
Brian Clozel opened SPR-13176 and commented
#17376 introduced the ability for a RequestBodyAdvice to turn empty input into some default value by iterating over all converters even when the body is empty. In some cases existing code that implicitly relies on the previous behavior (i.e. not looping over converters when the body is empty) may be affected.
For example consider the following from the referenced Boot ticket:
The above is arguably not ideal way to declare request mappings since GET requests should not have a body and they don't typically have a content-type (the
required=falseattribute is somewhat used as a workaround instead of creating a separate handler method for GET requests). In this scenario, previously Spring MVC would exit early due to the null body + required=false. Currently however it loops over converters, it picks application/octet-stream by default, and since no converter can handle that, it results in anHttpMediaTypeNotSupportedException.Affects: 4.2 RC1
Reference URL: spring-projects/spring-boot#3313
Issue Links:
@RequestBodyrequired parameter is ignored allowing null payloads ("is duplicated by")Referenced from: commits 3272a3b, 244c95b