diff --git a/spring-web/src/main/java/org/springframework/web/util/DisconnectedClientHelper.java b/spring-web/src/main/java/org/springframework/web/util/DisconnectedClientHelper.java index 2f443b133a19..4ba3441a4726 100644 --- a/spring-web/src/main/java/org/springframework/web/util/DisconnectedClientHelper.java +++ b/spring-web/src/main/java/org/springframework/web/util/DisconnectedClientHelper.java @@ -39,8 +39,7 @@ public class DisconnectedClientHelper { Set.of("broken pipe", "connection reset by peer"); private static final Set EXCEPTION_TYPE_NAMES = - Set.of("ClientAbortException", "EOFException", "EofException"); - + Set.of("AbortedException", "ClientAbortException", "EOFException", "EofException"); private final Log logger; @@ -51,6 +50,26 @@ public DisconnectedClientHelper(String logCategory) { } + /** + * Check via {@link #isClientDisconnectedException} if the exception + * indicates the remote client disconnected, and if so log a single line + * message when DEBUG is on, and a full stacktrace when TRACE is on for + * the configured logger. + */ + public boolean checkAndLogClientDisconnectedException(Throwable ex) { + if (isClientDisconnectedException(ex)) { + if (logger.isTraceEnabled()) { + logger.trace("Looks like the client has gone away", ex); + } + else if (logger.isDebugEnabled()) { + logger.debug("Looks like the client has gone away: " + ex + + " (For a full stack trace, set the log category '" + logger + "' to TRACE level.)"); + } + return true; + } + return false; + } + /** * Whether the given exception indicates the client has gone away. * Known cases covered: @@ -60,7 +79,7 @@ public DisconnectedClientHelper(String logCategory) { *
  • IOException "Broken pipe" or "connection reset by peer" * */ - public boolean isClientDisconnectedException(Throwable ex) { + public static boolean isClientDisconnectedException(Throwable ex) { String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage(); if (message != null) { String text = message.toLowerCase(); @@ -73,24 +92,4 @@ public boolean isClientDisconnectedException(Throwable ex) { return EXCEPTION_TYPE_NAMES.contains(ex.getClass().getSimpleName()); } - /** - * Check via {@link #isClientDisconnectedException} if the exception - * indicates the remote client disconnected, and if so log a single line - * message when DEBUG is on, and a full stacktrace when TRACE is on for - * the configured logger. - */ - public boolean checkAndLogClientDisconnectedException(Throwable ex) { - if (isClientDisconnectedException(ex)) { - if (logger.isTraceEnabled()) { - logger.trace("Looks like the client has gone away", ex); - } - else if (logger.isDebugEnabled()) { - logger.debug("Looks like the client has gone away: " + ex + - " (For a full stack trace, set the log category '" + logger + "' to TRACE level.)"); - } - return true; - } - return false; - } - }