Author: markt
Date: Thu Nov 21 09:35:51 2013
New Revision: 1544075

URL: http://svn.apache.org/r1544075
Log:
More https://issues.apache.org/bugzilla/show_bug.cgi?id=55799
If the connection is closed mid-message, report this cleanly back to the caller.

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
    tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties?rev=1544075&r1=1544074&r2=1544075&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties Thu 
Nov 21 09:35:51 2013
@@ -52,6 +52,7 @@ wsFrame.textMessageTooBig=The decoded te
 wsFrame.wrongRsv=The client frame set the reserved bits to [{0}] which was not 
supported by this endpoint
 
 wsRemoteEndpoint.closed=Message will not be sent because the WebSocket session 
has been closed
+wsRemoteEndpoint.closedDuringMessage=The remainder of the message will not be 
sent because the WebSocket session has been closed
 wsRemoteEndpoint.closedOutputStream=This method may not be called as the 
OutputStream has been closed
 wsRemoteEndpoint.closedWriter=This method may not be called as the Writer has 
been closed
 wsRemoteEndpoint.changeType=When sending a fragmented message, all fragments 
bust be of the same type

Modified: 
tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java?rev=1544075&r1=1544074&r2=1544075&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java 
Thu Nov 21 09:35:51 2013
@@ -66,7 +66,7 @@ public abstract class WsRemoteEndpointIm
     private final Object messagePartLock = new Object();
 
     // State
-    private boolean closed = false;
+    private volatile boolean closed = false;
     private boolean fragmented = false;
     private boolean nextFragmented = false;
     private boolean text = false;
@@ -605,7 +605,7 @@ public abstract class WsRemoteEndpointIm
     }
 
 
-    private static class TextMessageSendHandler implements SendHandler {
+    private class TextMessageSendHandler implements SendHandler {
 
         private final SendHandler handler;
         private final CharBuffer message;
@@ -645,6 +645,10 @@ public abstract class WsRemoteEndpointIm
                 handler.onResult(result);
             } else if(!result.isOK()) {
                 handler.onResult(result);
+            } else if (closed){
+                SendResult sr = new SendResult(new IOException(
+                        sm.getString("wsRemoteEndpoint.closedDuringMessage")));
+                handler.onResult(sr);
             } else {
                 write();
             }



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

Reply via email to