Skip to content

Indeterministic UnsatisfiedServletRequestParameterException#paramConditions [SPR-12854] #17452

@spring-projects-issues

Description

@spring-projects-issues

Adam Michalik opened SPR-12854 and commented

Consider a REST controller with the following request mappings on methods:

@RequestMapping(method = GET, params = "!myParam")
public void methodA(){...}

@RequestMapping(method = GET, params = "myParam=a")
public void methodB(){...}

When a request is made with myParam=b it does not match either of the mappings and an UnsatisfiedServletRequestParameterException is thrown in RequestMappingInfoHandlerMapping. However, the message of the exception is indeterministic - sometimes it's

Parameter conditions "myParam=a" not met for actual request parameters: myParam={b}

and sometimes

Parameter conditions "!myParam" not met for actual request parameters: myParam={b}

In my case it depended on which method was invoked first with a correct request after the server restart.
This is due to the logic in RequestMappingInfoHandlerMapping#getRequestParams where only first matching RequestMappingInfo is processed and the set of partialMatches is a HashSet with indeterministic order.


Affects: 4.1.6

Referenced from: commits b6449ba

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions