Skip to content

Request @RequestParam not enforced with empty values [SPR-10402] #15035

Closed
@spring-projects-issues

Description

@spring-projects-issues

Michael Osipov opened SPR-10402 and commented

I have defined this method signature:

@RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_XML_VALUE,
  "application/json;charset=UTF-8" })
public ResponseEntity<Object> searchProjects(@RequestParam(value = "q") String query,
  @RequestParam("attributes") String[] attributes,
  @RequestParam(value = "outputType", required = false, defaultValue = "hash") OutputType outputType)
  throws MissingServletRequestParameterException

When I invoke this method either with:

GET /rest?q&attributes=one

or

GET /rest?q=&attributes=one

The query variable is always passed as empty string/null although its defined as required. MissingServletRequestParameterException is not thrown.

I have attached a screenshot of the debugging session where one can inspect that case. I think the else if in lines 95 to 97 are incomplete.


Affects: 3.2.2

Attachments:

Issue Links:

Referenced from: commits 2d8315f, e39fe18, abfb439, d3eda09

0 votes, 7 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions