|
|
|
|
@ -39,8 +39,7 @@ public class DisconnectedClientHelper {
@@ -39,8 +39,7 @@ public class DisconnectedClientHelper {
|
|
|
|
|
Set.of("broken pipe", "connection reset by peer"); |
|
|
|
|
|
|
|
|
|
private static final Set<String> EXCEPTION_TYPE_NAMES = |
|
|
|
|
Set.of("ClientAbortException", "EOFException", "EofException"); |
|
|
|
|
|
|
|
|
|
Set.of("AbortedException", "ClientAbortException", "EOFException", "EofException"); |
|
|
|
|
|
|
|
|
|
private final Log logger; |
|
|
|
|
|
|
|
|
|
@ -51,6 +50,26 @@ public class DisconnectedClientHelper {
@@ -51,6 +50,26 @@ public class DisconnectedClientHelper {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 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 class DisconnectedClientHelper {
@@ -60,7 +79,7 @@ public class DisconnectedClientHelper {
|
|
|
|
|
* <li>IOException "Broken pipe" or "connection reset by peer" |
|
|
|
|
* </ul> |
|
|
|
|
*/ |
|
|
|
|
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 class DisconnectedClientHelper {
@@ -73,24 +92,4 @@ public class DisconnectedClientHelper {
|
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|