You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@RequestBody should have a required parameter to allow a request body to be optional [SPR-9239] #13877
@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.
Iv tested this on 3.2M2 and set @RequestBody(required=false), and it is still throwing org.springframework.http.converter.HttpMessageNotReadableException when I send it a null body from a test client. I would expect my body object parameter to be sent through as null, as per the comments on the @RequestBody.required() method.
Activity
spring-projects-issues commentedon Mar 20, 2012
Chris Beams commented
Assigning to you
@Arjenas this looks closely related to #13876 (which you are also assigned to). Added@Rossenas watcher.spring-projects-issues commentedon Oct 29, 2012
David Roberts commented
Iv tested this on 3.2M2 and set
@RequestBody(required=false), and it is still throwing org.springframework.http.converter.HttpMessageNotReadableException when I send it a null body from a test client. I would expect my body object parameter to be sent through as null, as per the comments on the@RequestBody.required() method.Any suggestions?
spring-projects-issues commentedon Oct 31, 2012
Rossen Stoyanchev commented
I've created a new issue #14575 to track the reported problem.
spring-projects-issues commentedon Feb 7, 2016
Izek Greenfield commented
I see this problem happen in version 4.2.3-RELEASE