Package org.springframework.web.util

# Class DisconnectedClientHelper

java.lang.Object
org.springframework.web.util.DisconnectedClientHelper

public class DisconnectedClientHelper extends Object
Utility methods to assist with identifying and logging exceptions that indicate the server response connection is lost, for example because the client has gone away. This class helps to identify such exceptions and minimize logging to a single line at DEBUG level, while making the full error stacktrace at TRACE level.

Since:
  6.1
Author:
  Rossen Stoyanchev, Yanming Zhou

## Constructor Summary

Constructors
Constructor
Description
`DisconnectedClientHelper(String logCategory)`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`checkAndLogClientDisconnectedException(Throwable ex)`
Check via `isClientDisconnectedException(java.lang.Throwable)` 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.
`static boolean`
`isClientDisconnectedException(Throwable ex)`
Whether the given exception indicates the client has gone away.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DisconnectedClientHelper

public DisconnectedClientHelper(String logCategory)

## Method Details

### checkAndLogClientDisconnectedException

public boolean checkAndLogClientDisconnectedException(Throwable ex)
Check via `isClientDisconnectedException(java.lang.Throwable)` 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.

### isClientDisconnectedException

public static boolean isClientDisconnectedException(@Nullable Throwable ex)
Whether the given exception indicates the client has gone away.

Known cases covered:

- ClientAbortException or EOFException for Tomcat
- EofException for Jetty
- IOException "Broken pipe" or "connection reset by peer"