Skip to content

RequestMappingInfoHandlerMapping.handleNoMatch returns null instead of throwing an exception [SPR-10193] #14826

@spring-projects-issues

Description

@spring-projects-issues

Shelley J. Baker opened SPR-10193 and commented

Update: Original request below is to raise HttpRequestMethodNotSupportedException. Actual solution raises UnsatisfiedServletRequestParameterException.


When a request is made to a URI using an unsupported method, a 404 error is returned instead of a 405 when another mapping exists for that method with matching parameters.

For example, given the following mappings:

@Controller
@RequestMapping("/test")
public class TestController {

    @RequestMapping(method = RequestMethod.GET)
    public void get() {}

    @RequestMapping(method = RequestMethod.POST, params = "test")
    public void post() {}
}

The following occurs:

POST /test

expected: 405
actual: 404

Specifically, the RequestMappingInfoHandlerMapping handleNoMatch method returns null instead of throwing the HttpRequestMethodNotSupportedException as expected.

This is a regression between 3.1.2 and 3.1.3; previously, the 405 occurred as expected. This may be related to the changes introduced by #14237.


Affects: 3.1.3

Referenced from: commits 72013f9, 3c09b07

Backported to: 3.1.4

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions