-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Expose mapped handler as request attribute in spring-webmvc [SPR-17518] #22050
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 The |
Andy Wilkinson commented If the behaviour cannot be changed to align with the documented contract, can the javadoc please be updated? It would also be useful if it was possible for callers to distinguish between exceptions that are internal errors and exceptions that are being used as a way of affecting the response status. |
Rossen Stoyanchev commented
In practice I know split handling of a URL can sometimes occur. For example Spring Data REST is careful to use a different stereotype annotation. We could consider some improvement to the assumptions that RequestMappingHandlerMapping makes, or how the contract is defined, but for that it would be useful to precise the needs. I'm not sure I understand the scenario very well. In any case adding an extra comment in the contract would be no problem. As for differentiating exceptions, I don't really have a good answer other than it's the ones handled in |
Andy Wilkinson commented There's a bit of background in the referenced Boot issue and the Micrometer issue to which it links. Both Boot and Micrometer use |
Rossen Stoyanchev commented As evident from Performance implications aside, looking up a handler outside the For Micrometer specifically, what makes it a requirement to look up the handler before, as opposed to after the filter chain, for example by getting it from a request attribute? On the WebFlux side we have such an attribute
|
Andy Wilkinson commented I'm a bit hazy on the specifics as the code was developed in Micrometer before it moved into Boot and I'm guilty of not giving it the scrutiny it deserved when it moved over. That said, I believe that the handler is needed to support |
Rossen Stoyanchev commented Okay I'll go ahead and add the request attribute for now, providing parity with Webflux. How far back do you need it backported to? It should be free of side effects, but nevertheless.. |
Rossen Stoyanchev commented Now available in master with #a55ca5. |
Andy Wilkinson commented Thanks, Rossen. For Boot it would be useful to have the change in Framework 5.0 in addition to 5.1. For Micrometer, it may be useful to have it in 4.3 as well for use in their Spring Boot 1.5 integration. |
Johnny Lim opened SPR-17518 and commented
Javadoc for
HandlerMapping.getHandler()
says it will returnnull
if no mapping found butRequestMappingHandlerMapping.getHandler()
throwsHttpRequestMethodNotSupportedException
instead.There's a sample project to reproduce it in the "Reference URL".
Affects: 4.3.20
Reference URL: spring-projects/spring-boot#15204
Referenced from: commits 736b3c4, a55ca56, abacc6d
Backported to: 5.0.11, 4.3.21
The text was updated successfully, but these errors were encountered: