Don't print ClosedChannelException when we actually asked to close the connection.
This commit is contained in:
parent
5b40c4aabb
commit
e4a5bf0eac
@ -5,6 +5,7 @@ import org.eclipse.jetty.websocket.api.Session;
|
|||||||
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
|
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.channels.ClosedChannelException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,6 +13,8 @@ import java.time.Duration;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractServerWS extends WebSocketAdapter implements AbstractWS {
|
public abstract class AbstractServerWS extends WebSocketAdapter implements AbstractWS {
|
||||||
|
|
||||||
|
private boolean isClosed = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onWebSocketConnect(Session sess)
|
public final void onWebSocketConnect(Session sess)
|
||||||
{
|
{
|
||||||
@ -37,6 +40,8 @@ public abstract class AbstractServerWS extends WebSocketAdapter implements Abstr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onWebSocketError(Throwable cause) {
|
public final void onWebSocketError(Throwable cause) {
|
||||||
|
if (isClosed && cause instanceof ClosedChannelException)
|
||||||
|
return; // ignore because this exception is expected when we just sent a close packet.
|
||||||
onError(cause);
|
onError(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +58,7 @@ public abstract class AbstractServerWS extends WebSocketAdapter implements Abstr
|
|||||||
@Override
|
@Override
|
||||||
public final void sendClose(int code, String reason) throws IOException {
|
public final void sendClose(int code, String reason) throws IOException {
|
||||||
getSession().close(code, reason);
|
getSession().close(code, reason);
|
||||||
|
isClosed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user