Skip to content

RequestMappingInfoHandlerMapping.handleNoMatch throws HttpRequestMethodNotSupportedException incorrectly [SPR-9603] #14237

Closed
@spring-projects-issues

Description

@spring-projects-issues

elliot barlas opened SPR-9603 and commented

The handleNoMatch method of the RequestMappingInfoHandlerMapping class incorrectly throws HttpRequestMethodNotSupportedException if:

  • A request handler method exists that matches the path and methods but not produce/consume expression
  • Another request handler method exists that matches the path but not the method

In this case, the handleNoMatch method finds the request handler method that matches the path but not the method, resulting in a HttpRequestMethodNotSupportedException (line 135).

Example:

Request sent for "/users" with "Accept: application/xml"

@RequestMapping(value = "/users", method = GET, produces = "application/json")
public void foo() {...}

@RequestMapping(value = "/users", method = PUT)
public void bar() {...}

Expected exception HttpMediaTypeNotAcceptableException, observed exception HttpRequestMethodNotSupportedException.


Affects: 3.1 GA

Issue Links:

Referenced from: commits 473de08, f78bef9

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions