Apparently the ExceptionHandlerExceptionResolver despite having the proper #setCustomArgumentResolvers does not register the arguments resolver that are being registered within web application through WebMvcConfigurerAdapters.
Whether this has been done for purpose, I think that this could be extended to allow additional argument resolutions in the error handling methods like for instance: https://jira.spring.io/browse/SEC-2696
Affects: 4.0.6, 4.2.4
SEC-2696 Can not inject @AuthenticationPrincipal into @ExceptionHandler method. ("is duplicated by")
Referenced from: pull request #615, and commits 1cf0fb8
The text was updated successfully, but these errors were encountered:
An @RequestMapping method supports a much wider range of argument types (@ExceptionHandler only registers request and response related argument resolvers) so they are different sets. The javadoc on WebMvcConfigurer is also quite explicit that it only applies to RequestMappingHandlerAdapter.
That said it might be okay to apply this change as an improvement since custom argument resolvers, which are invoked after built-in ones, would have be of a specific type or have a specific annotation. Hence registering custom resolvers shouldn't cause any harm. For consistency the change should also apply to the MVC XML namespace as well custom HandlerMethodReturnValueHandler's.