Author: markt Date: Wed Mar 6 17:30:30 2013 New Revision: 1453443 URL: http://svn.apache.org/r1453443 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54612 Check if socket is closed before trying to write a message to it. Also, flush any partial buffered data before closing the socket.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/WsOutbound.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1453439 Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/WsOutbound.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/WsOutbound.java?rev=1453443&r1=1453442&r2=1453443&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/WsOutbound.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/WsOutbound.java Wed Mar 6 17:30:30 2013 @@ -269,6 +269,10 @@ public class WsOutbound { if (closed) { return; } + + // Send any partial data we have + doFlush(false); + closed = true; upgradeOutbound.write(0x88); @@ -355,6 +359,10 @@ public class WsOutbound { private void doWriteBytes(ByteBuffer buffer, boolean finalFragment) throws IOException { + if (closed) { + throw new IOException(sm.getString("outbound.closed")); + } + // Work out the first byte int first = 0x00; if (finalFragment) { Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1453443&r1=1453442&r2=1453443&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Wed Mar 6 17:30:30 2013 @@ -266,6 +266,11 @@ Allow WebSocket Ping/Pong messages to be sent between fragments of a fragmented message. (markt) </fix> + <fix> + <bug>54612</bug>: Check if the socket is closed before trying to write a + WebSocket message to it. Also, flush any partial buffered data before + closing the socket. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org