Author: markt Date: Mon Feb 23 20:36:29 2015 New Revision: 1661770 URL: http://svn.apache.org/r1661770 Log: Fix hanging WebSocket unit test on Windows.
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1661770&r1=1661769&r2=1661770&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Mon Feb 23 20:36:29 2015 @@ -473,12 +473,10 @@ public class WsSession implements Sessio fireEndpointOnError(e); } - state = State.CLOSING; + state = State.OUTPUT_CLOSED; sendCloseMessage(closeReasonMessage); fireEndpointOnClose(closeReasonLocal); - - state = State.CLOSED; } IOException ioe = new IOException(sm.getString("wsSession.messageFailed")); @@ -500,7 +498,7 @@ public class WsSession implements Sessio public void onClose(CloseReason closeReason) { synchronized (stateLock) { - if (state == State.OPEN) { + if (state != State.CLOSED) { try { wsRemoteEndpoint.setBatchingAllowed(false); } catch (IOException e) { @@ -510,10 +508,10 @@ public class WsSession implements Sessio sendCloseMessage(closeReason); fireEndpointOnClose(closeReason); state = State.CLOSED; - } - // Close the socket - wsRemoteEndpoint.close(); + // Close the socket + wsRemoteEndpoint.close(); + } } } @@ -733,13 +731,17 @@ public class WsSession implements Sessio private void checkState() { if (state == State.CLOSED) { + /* + * As per RFC 6455, a WebSocket connection is considered to be + * closed once a peer has sent and received a WebSocket close frame. + */ throw new IllegalStateException(sm.getString("wsSession.closed", id)); } } private static enum State { OPEN, - CLOSING, + OUTPUT_CLOSED, CLOSED } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org