Description
Michel Zanini opened SPR-9239 and commented
@RequestBody
should have a required parameter to allow a request body to be optional, if the body is empty my object is null, otherwise it is parsed using a http message converter.
At the moment I am using a Jackson (JSON) converter and if I use it as bellow:
@RequestMapping
(method = RequestMethod.POST, value = "/url")
public String method(@RequestBody
MyBody myBody) {
...
}
Then, if I send an empty body it will throw an java.io.EOFException.
In this case I would like to receive null in myBody and execute my method anyway.
This issue maybe related to https://jira.springsource.org/browse/SPR-9238.
Affects: 3.1.1
Issue Links:
- Contract of @RequestBody(required=true) not obeyed [SPR-11828] #16447 Contract of
@RequestBody
(required=true) not obeyed - JSON (jackson) @RequestBody marshalling throws java.io.EOFException when body is missing [SPR-9238] #13876 JSON (jackson)
@RequestBody
marshalling throws java.io.EOFException when body is missing - HttpMessageNotReadableException when @RequestBody(required=false) [SPR-9942] #14575 HttpMessageNotReadableException when
@RequestBody
(required=false) - Support for java.util.Optional as a @RequestBody [SPR-15007] #19574 Support for java.util.Optional as a
@RequestBody
Referenced from: commits spring-attic/spring-framework-issues@208a6cb
1 votes, 3 watchers