|
58 | 58 | import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
59 | 59 | import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
|
60 | 60 | import org.springframework.web.servlet.support.RequestContextUtils;
|
| 61 | +import org.springframework.web.util.DisconnectedClientHelper; |
61 | 62 |
|
62 | 63 | /**
|
63 | 64 | * An {@link AbstractHandlerMethodExceptionResolver} that resolves exceptions
|
|
76 | 77 | public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExceptionResolver
|
77 | 78 | implements ApplicationContextAware, InitializingBean {
|
78 | 79 |
|
| 80 | + /** |
| 81 | + * Log category to use for network failure after a client has gone away. |
| 82 | + * @see DisconnectedClientHelper |
| 83 | + */ |
| 84 | + private static final String DISCONNECTED_CLIENT_LOG_CATEGORY = |
| 85 | + "org.springframework.web.servlet.mvc.method.annotation.DisconnectedClient"; |
| 86 | + |
| 87 | + private static final DisconnectedClientHelper disconnectedClientHelper = |
| 88 | + new DisconnectedClientHelper(DISCONNECTED_CLIENT_LOG_CATEGORY); |
| 89 | + |
| 90 | + |
79 | 91 | @Nullable
|
80 | 92 | private List<HandlerMethodArgumentResolver> customArgumentResolvers;
|
81 | 93 |
|
@@ -420,10 +432,12 @@ protected ModelAndView doResolveHandlerMethodException(HttpServletRequest reques
|
420 | 432 | exceptionHandlerMethod.invokeAndHandle(webRequest, mavContainer, arguments);
|
421 | 433 | }
|
422 | 434 | catch (Throwable invocationEx) {
|
423 |
| - // Any other than the original exception (or a cause) is unintended here, |
424 |
| - // probably an accident (e.g. failed assertion or the like). |
425 |
| - if (!exceptions.contains(invocationEx) && logger.isWarnEnabled()) { |
426 |
| - logger.warn("Failure in @ExceptionHandler " + exceptionHandlerMethod, invocationEx); |
| 435 | + if (!disconnectedClientHelper.checkAndLogClientDisconnectedException(invocationEx)) { |
| 436 | + // Any other than the original exception (or a cause) is unintended here, |
| 437 | + // probably an accident (e.g. failed assertion or the like). |
| 438 | + if (!exceptions.contains(invocationEx) && logger.isWarnEnabled()) { |
| 439 | + logger.warn("Failure in @ExceptionHandler " + exceptionHandlerMethod, invocationEx); |
| 440 | + } |
427 | 441 | }
|
428 | 442 | // Continue with default processing of the original exception...
|
429 | 443 | return null;
|
|
0 commit comments