Mark response errors from @ExceptionHandler as handled

Also fix a couple of related issues:
- add AsyncRequestNotUsableException to the list of exceptions
that imply response issues.
- handle exceptions from @ExceptionHandler regardless of whether
thrown immediately or via Publisher.

Closes gh-32359
This commit is contained in:
rstoyanchev
2024-03-06 18:01:29 +00:00
parent 0955f541cb
commit 5f601ceb45
5 changed files with 69 additions and 16 deletions

View File

@@ -432,12 +432,13 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
exceptionHandlerMethod.invokeAndHandle(webRequest, mavContainer, arguments);
}
catch (Throwable invocationEx) {
if (!disconnectedClientHelper.checkAndLogClientDisconnectedException(invocationEx)) {
// Any other than the original exception (or a cause) is unintended here,
// probably an accident (e.g. failed assertion or the like).
if (!exceptions.contains(invocationEx) && logger.isWarnEnabled()) {
logger.warn("Failure in @ExceptionHandler " + exceptionHandlerMethod, invocationEx);
}
if (disconnectedClientHelper.checkAndLogClientDisconnectedException(invocationEx)) {
return new ModelAndView();
}
// Any other than the original exception (or a cause) is unintended here,
// probably an accident (e.g. failed assertion or the like).
if (!exceptions.contains(invocationEx) && logger.isWarnEnabled()) {
logger.warn("Failure in @ExceptionHandler " + exceptionHandlerMethod, invocationEx);
}
// Continue with default processing of the original exception...
return null;