Skip to content
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

Add more default HandlerMethodArgumentResolver's to ExceptionHandlerExceptionResolver [SPR-15489] #20049

spring-issuemaster opened this issue Apr 26, 2017 · 0 comments


Copy link

@spring-issuemaster spring-issuemaster commented Apr 26, 2017

Feliks Khantsis opened SPR-15489 and commented

The documentation at 22.11.2 says that

Much like standard controller methods annotated with a @RequestMapping annotation, the method arguments and return values of @ExceptionHandler methods can be flexible.

However in reality, ExceptionHandlerExceptionResolver#getDefaultArgumentResolvers is much skimmer than RequestMappingHandlerAdapter#getDefaultArgumentResolvers. There is no documentation which resolvers are or are not part of ExceptionHandlerExceptionResolver's defaults.

Specifically, I need RequestHeaderMethodArgumentResolver. My use case is that server requirements changed, and now under certain conditions, the server must not accept a request, and return 400-BadRequest. However since some clients are not yet updated, this will cause them to crash. Therefore, new clients send a custom header to say that they are ready to receive 400-BadRequest. Thus, in the @ExceptionHandler method, if the new header is set, then we can return 400, otherwise, keep returning 200. Unfortunately, I can't get the header via @RequestHeader, since RequestHeaderMethodArgumentResolver is not in ExceptionHandlerExceptionResolver.

At best, you should equate all default handlers for ExceptionHandlerExceptionResolver and RequestMappingHandlerAdapter. If that's impossible, then at least go through all argument resolvers that are not in ExceptionHandlerExceptionResolver, re-evaluate if it's impossible to move it to Ex.HandlerEx.Resolver, and have clear documentation in 22.11.2 as for which argument and return value handlers are supported, and which are not.

No further details from SPR-15489

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.