Minor improvement in ExceptionHandlerExceptionResolver
Moved a null check inside a protected method to give protected method a chance to override what happens in that case. Issues: SPR-9193
This commit is contained in:
parent
a17a889e8a
commit
97c22fc08e
|
@ -250,12 +250,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
|||
*/
|
||||
@Override
|
||||
protected ModelAndView doResolveHandlerMethodException(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
HandlerMethod handlerMethod,
|
||||
Exception exception) {
|
||||
if (handlerMethod == null) {
|
||||
return null;
|
||||
}
|
||||
HttpServletResponse response, HandlerMethod handlerMethod, Exception exception) {
|
||||
|
||||
ServletInvocableHandlerMethod exceptionHandlerMethod = getExceptionHandlerMethod(handlerMethod, exception);
|
||||
if (exceptionHandlerMethod == null) {
|
||||
|
@ -296,11 +291,14 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
|||
* Find the @{@link ExceptionHandler} method for the given exception.
|
||||
* The default implementation searches @{@link ExceptionHandler} methods
|
||||
* in the class hierarchy of the method that raised the exception.
|
||||
* @param handlerMethod the method where the exception was raised
|
||||
* @param handlerMethod the method where the exception was raised, possibly {@code null}
|
||||
* @param exception the raised exception
|
||||
* @return a method to handle the exception, or {@code null}
|
||||
*/
|
||||
protected ServletInvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) {
|
||||
if (handlerMethod == null) {
|
||||
return null;
|
||||
}
|
||||
Class<?> handlerType = handlerMethod.getBeanType();
|
||||
Method method = getExceptionHandlerMethodResolver(handlerType).resolveMethod(exception);
|
||||
return (method != null ? new ServletInvocableHandlerMethod(handlerMethod.getBean(), method) : null);
|
||||
|
|
Loading…
Reference in New Issue