You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2016/04/14 21:48:25 UTC

svn commit: r1739172 - in /tomcat/trunk: java/org/apache/tomcat/websocket/WsSession.java webapps/docs/changelog.xml

Author: markt
Date: Thu Apr 14 19:48:25 2016
New Revision: 1739172

URL: http://svn.apache.org/viewvc?rev=1739172&view=rev
Log:
Make WebSocket client more robist when handling errors during the close of a WebSocket session.

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
    tomcat/trunk/webapps/docs/changelog.xml

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=1739172&r1=1739171&r2=1739172&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Thu Apr 14 19:48:25 2016
@@ -19,6 +19,7 @@ package org.apache.tomcat.websocket;
 import java.io.IOException;
 import java.net.URI;
 import java.nio.ByteBuffer;
+import java.nio.channels.WritePendingException;
 import java.nio.charset.StandardCharsets;
 import java.security.Principal;
 import java.util.Collections;
@@ -590,13 +591,12 @@ public class WsSession implements Sessio
         }
         msg.flip();
         try {
-            wsRemoteEndpoint.sendMessageBlock(
-                    Constants.OPCODE_CLOSE, msg, true);
-        } catch (IOException ioe) {
+            wsRemoteEndpoint.sendMessageBlock(Constants.OPCODE_CLOSE, msg, true);
+        } catch (IOException | WritePendingException e) {
             // Failed to send close message. Close the socket and let the caller
             // deal with the Exception
             if (log.isDebugEnabled()) {
-                log.debug(sm.getString("wsSession.sendCloseFail", id), ioe);
+                log.debug(sm.getString("wsSession.sendCloseFail", id), e);
             }
             wsRemoteEndpoint.close();
             // Failure to send a close message is not unexpected in the case of
@@ -604,7 +604,7 @@ public class WsSession implements Sessio
             // from/to the client. In this case do not trigger the endpoint's
             // error handling
             if (closeCode != CloseCodes.CLOSED_ABNORMALLY) {
-                localEndpoint.onError(this, ioe);
+                localEndpoint.onError(this, e);
             }
         } finally {
             webSocketContainer.unregisterSession(localEndpoint, this);

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1739172&r1=1739171&r2=1739172&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Apr 14 19:48:25 2016
@@ -196,6 +196,10 @@
         Ensure that a client disconnection triggers the error handling for the
         associated WebSocket end point. (markt)
       </fix>
+      <add>
+        Make WebSocket client more robist when handling errors during the close
+        of a WebSocket session. (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Web applications">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org