[jbossweb-commits] JBossWeb SVN: r2281 - branches/7.4.x/src/main/java/org/apache/tomcat/websocket.

jbossweb-commits at lists.jboss.org jbossweb-commits at lists.jboss.org
Wed Oct 16 08:44:02 EDT 2013


Author: remy.maucherat at jboss.com
Date: 2013-10-16 08:44:02 -0400 (Wed, 16 Oct 2013)
New Revision: 2281

Modified:
   branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java
Log:
Pour WS patch.

Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java	2013-10-16 10:48:32 UTC (rev 2280)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java	2013-10-16 12:44:02 UTC (rev 2281)
@@ -32,6 +32,7 @@
 import java.util.concurrent.atomic.AtomicLong;
 
 import javax.websocket.CloseReason;
+import javax.websocket.CloseReason.CloseCode;
 import javax.websocket.CloseReason.CloseCodes;
 import javax.websocket.DeploymentException;
 import javax.websocket.Endpoint;
@@ -460,7 +461,8 @@
     private void sendCloseMessage(CloseReason closeReason) {
         // 125 is maximum size for the payload of a control message
         ByteBuffer msg = ByteBuffer.allocate(125);
-        msg.putShort((short) closeReason.getCloseCode().getCode());
+        CloseCode closeCode = closeReason.getCloseCode();
+        msg.putShort((short) closeCode.getCode());
 
         String reason = closeReason.getReasonPhrase();
         if (reason != null && reason.length() > 0) {
@@ -475,7 +477,13 @@
             // deal with the Exception
             WebsocketsLogger.ROOT_LOGGER.closeMessageFail(ioe);
             wsRemoteEndpoint.close();
-            localEndpoint.onError(this, ioe);
+            // Failure to send a close message is not unexpected in the case of
+            // an abnormal closure (usually triggered by a failure to read/write
+            // from/to the client. In this case do not trigger the endpoint's
+            // error handling
+            if (closeCode != CloseCodes.CLOSED_ABNORMALLY) {
+                localEndpoint.onError(this, ioe);
+            }
         } finally {
             webSocketContainer.unregisterSession(localEndpoint, this);
         }



More information about the jbossweb-commits mailing list