Author: markt Date: Thu Apr 14 19:49:20 2016 New Revision: 1739173 URL: http://svn.apache.org/viewvc?rev=1739173&view=rev Log: Make WebSocket client more robist when handling errors during the close of a WebSocket session.
Modified: tomcat/tc8.5.x/trunk/ (props changed) tomcat/tc8.5.x/trunk/java/org/apache/tomcat/websocket/WsSession.java tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc8.5.x/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Apr 14 19:49:20 2016 @@ -1 +1 @@ -/tomcat/trunk:1734785,1734799,1734845,1734928,1735041,1735044,1735480,1735577,1735597,1735599-1735600,1735615,1736145,1736162,1736209,1736280,1736297,1736299,1736489,1736646,1736703,1736836,1736849,1737104-1737105,1737112,1737117,1737119-1737120,1737155,1737157,1737192,1737280,1737339,1737632,1737664,1737715,1737748,1737785,1737834,1737860,1737959,1738005,1738007,1738014-1738015,1738018,1738022,1738039,1738043,1738059-1738060,1738147,1738149,1738174-1738175,1738261,1738589,1738623-1738625,1738643,1738816,1738850,1738855,1738946-1738948,1738953-1738954,1738979,1738982,1739079-1739081,1739087,1739113,1739153 +/tomcat/trunk:1734785,1734799,1734845,1734928,1735041,1735044,1735480,1735577,1735597,1735599-1735600,1735615,1736145,1736162,1736209,1736280,1736297,1736299,1736489,1736646,1736703,1736836,1736849,1737104-1737105,1737112,1737117,1737119-1737120,1737155,1737157,1737192,1737280,1737339,1737632,1737664,1737715,1737748,1737785,1737834,1737860,1737959,1738005,1738007,1738014-1738015,1738018,1738022,1738039,1738043,1738059-1738060,1738147,1738149,1738174-1738175,1738261,1738589,1738623-1738625,1738643,1738816,1738850,1738855,1738946-1738948,1738953-1738954,1738979,1738982,1739079-1739081,1739087,1739113,1739153,1739172 Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/websocket/WsSession.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1739173&r1=1739172&r2=1739173&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/websocket/WsSession.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/websocket/WsSession.java Thu Apr 14 19:49:20 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/tc8.5.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml?rev=1739173&r1=1739172&r2=1739173&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Thu Apr 14 19:49:20 2016 @@ -190,6 +190,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-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org