-
Notifications
You must be signed in to change notification settings - Fork 38.5k
RequestMappingInfoHandlerMapping.handleNoMatch returns null instead of throwing an exception [SPR-10193] #14826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Rossen Stoyanchev commented Why do you consider 405 to be the correct status? POST is allowed! The issue is with the missing parameter. It would be strange also to issue a POST request and to get back a 405 with the "Allow" response header listing GET and POST. |
Shelley J. Baker commented Because a POST is not allowed at the specified Request-URI, I suppose you could make the argument that a |
Rossen Stoyanchev commented Hm, I see what you mean about the parameter being included in the resource URI. However, I do think that can vary by use case. It's more common to use the path to identify the resource while query parameters may or may not apply. For example a product id in the query, helps to identify the target resource but a search results parameter does not. I do agree that returning 404 is not the most intuitive outcome either. Perhaps raising UnsatisfiedServletRequestParameterException as the DefaultAnnotationHandlerMapping does? That gets translated into a 400 error via DefaultHandlerExceptionResolver. |
Shelley J. Baker commented I agree that query params are commonly used as you described, in which case a The |
Rossen Stoyanchev commented Well, I disagree that simply requiring a parameter makes it part of what identifies the target resource. I can require items completely unrelated to the target resource in which case returning 405 is odd. 400 is what we've been returning in case of missing Servlet request parameters for a while except in the case of |
Rossen Stoyanchev commented RequestMappingInfoHandlerMapping now raises UnsatisfiedServletRequestParameterException if there are unmatched request mapping parameter conditions. |
Shelley J. Baker opened SPR-10193 and commented
Update: Original request below is to raise
HttpRequestMethodNotSupportedException
. Actual solution raisesUnsatisfiedServletRequestParameterException
.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:
The following occurs:
expected: 405
actual: 404
Specifically, the
RequestMappingInfoHandlerMapping
handleNoMatch
method returnsnull
instead of throwing theHttpRequestMethodNotSupportedException
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
The text was updated successfully, but these errors were encountered: