Skip to content

@RequestBody should have a required parameter to allow a request body to be optional [SPR-9239] #13877

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits spring-attic/spring-framework-issues@208a6cb

1 votes, 3 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions