396518 - Websocket AB Tests should test for which side disconnected and closed.wasClean
+ adding AbstractWebSocketConnection.onWriteWebSocketClose() to allow for different behavior between client vs server TCP disconnect logic.
This commit is contained in:
parent
2c583ccda4
commit
60598c5c73
|
@ -103,11 +103,17 @@ public abstract class EventDriver implements IncomingFrames
|
|||
// notify user websocket pojo
|
||||
onClose(close);
|
||||
|
||||
// respond
|
||||
session.close(close.getStatusCode(),close.getReason());
|
||||
|
||||
// process handshake
|
||||
session.getConnection().getIOState().onCloseHandshake(true,close);
|
||||
if (session.getConnection().getIOState().onCloseHandshake(true,close))
|
||||
{
|
||||
// handshake resolved, disconnect.
|
||||
session.getConnection().disconnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
// respond
|
||||
session.close(close.getStatusCode(),close.getReason());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -169,10 +169,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
if (frame.getType().getOpCode() == OpCode.CLOSE)
|
||||
{
|
||||
CloseInfo close = new CloseInfo(origPayload,false);
|
||||
if (ioState.onCloseHandshake(false,close))
|
||||
{
|
||||
disconnect();
|
||||
}
|
||||
// TODO: change into DisconnectWebSocketCallback
|
||||
onWriteWebSocketClose(close);
|
||||
}
|
||||
|
||||
getBufferPool().release(origPayload);
|
||||
|
@ -580,6 +578,14 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
return true;
|
||||
}
|
||||
|
||||
public void onWriteWebSocketClose(CloseInfo close)
|
||||
{
|
||||
if (ioState.onCloseHandshake(false,close))
|
||||
{
|
||||
disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
|
|
|
@ -144,11 +144,9 @@ public class IOState
|
|||
return true;
|
||||
}
|
||||
|
||||
if (close.isHarsh())
|
||||
{
|
||||
LOG.debug("Close status code was harsh, disconnecting");
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* if (close.isHarsh()) { LOG.debug("Close status code was harsh, disconnecting"); return true; }
|
||||
*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
|
||||
import org.eclipse.jetty.websocket.common.CloseInfo;
|
||||
import org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection;
|
||||
|
||||
public class WebSocketServerConnection extends AbstractWebSocketConnection
|
||||
|
@ -71,6 +72,13 @@ public class WebSocketServerConnection extends AbstractWebSocketConnection
|
|||
super.onOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWriteWebSocketClose(CloseInfo close)
|
||||
{
|
||||
// as server, always disconnect if writing close
|
||||
disconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextIncomingFrames(IncomingFrames incoming)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,7 @@ public class WebSocketInvalidVersionTest
|
|||
}
|
||||
finally
|
||||
{
|
||||
client.close();
|
||||
client.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -624,6 +624,10 @@ public class BlockheadClient implements IncomingFrames, OutgoingFrames
|
|||
|
||||
public void write(WebSocketFrame frame) throws IOException
|
||||
{
|
||||
if (!ioState.isOpen())
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOG.debug("write(Frame->{}) to {}",frame,outgoing);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue