Issue #3849 - only notify onError for local errors
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
9902794988
commit
9449008581
|
@ -22,7 +22,6 @@ import java.io.IOException;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.channels.ClosedChannelException;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -317,7 +316,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
|
||||||
connection.close();
|
connection.close();
|
||||||
|
|
||||||
// Forward Errors to Local WebSocket EndPoint
|
// Forward Errors to Local WebSocket EndPoint
|
||||||
if (closeStatus.isAbnormal())
|
if (closeStatus.isAbnormal() && closeStatus.getCause() != null)
|
||||||
{
|
{
|
||||||
Callback errorCallback = Callback.from(() ->
|
Callback errorCallback = Callback.from(() ->
|
||||||
{
|
{
|
||||||
|
@ -332,7 +331,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Throwable cause = closeStatus.getCause() != null ? closeStatus.getCause() : new ClosedChannelException();
|
Throwable cause = closeStatus.getCause();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
handler.onError(cause, errorCallback);
|
handler.onError(cause, errorCallback);
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.websocket.core.internal;
|
package org.eclipse.jetty.websocket.core.internal;
|
||||||
|
|
||||||
|
import java.nio.channels.ClosedChannelException;
|
||||||
|
|
||||||
import org.eclipse.jetty.websocket.core.CloseStatus;
|
import org.eclipse.jetty.websocket.core.CloseStatus;
|
||||||
import org.eclipse.jetty.websocket.core.Frame;
|
import org.eclipse.jetty.websocket.core.Frame;
|
||||||
import org.eclipse.jetty.websocket.core.OpCode;
|
import org.eclipse.jetty.websocket.core.OpCode;
|
||||||
|
@ -133,7 +135,7 @@ public class WebSocketSessionState
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (_closeStatus == null || CloseStatus.isOrdinary(_closeStatus.getCode()))
|
if (_closeStatus == null || CloseStatus.isOrdinary(_closeStatus.getCode()))
|
||||||
_closeStatus = new CloseStatus(CloseStatus.NO_CLOSE, "Session Closed");
|
_closeStatus = new CloseStatus(CloseStatus.NO_CLOSE, "Session Closed", new ClosedChannelException());
|
||||||
_sessionState = State.CLOSED;
|
_sessionState = State.CLOSED;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.core.proxy;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.nio.channels.ClosedChannelException;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
|
@ -281,6 +282,23 @@ class WebSocketProxy
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("[{}] onClosed {}", toString(), closeStatus);
|
LOG.debug("[{}] onClosed {}", toString(), closeStatus);
|
||||||
|
|
||||||
|
boolean abnormalClose = false;
|
||||||
|
synchronized (lock)
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case CLOSED:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abnormalClose = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abnormalClose)
|
||||||
|
server2Proxy.fail(new ClosedChannelException(), Callback.NOOP);
|
||||||
|
|
||||||
closed.countDown();
|
closed.countDown();
|
||||||
callback.succeeded();
|
callback.succeeded();
|
||||||
}
|
}
|
||||||
|
@ -568,6 +586,24 @@ class WebSocketProxy
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("[{}] onClosed {}", toString(), closeStatus);
|
LOG.debug("[{}] onClosed {}", toString(), closeStatus);
|
||||||
|
|
||||||
|
boolean abnormalClose = false;
|
||||||
|
synchronized (lock)
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case CLOSED:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abnormalClose = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abnormalClose)
|
||||||
|
client2Proxy.fail(new ClosedChannelException(), Callback.NOOP);
|
||||||
|
|
||||||
closed.countDown();
|
closed.countDown();
|
||||||
callback.succeeded();
|
callback.succeeded();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue