Author: markt
Date: Mon Apr 29 12:28:00 2013
New Revision: 1476996

URL: http://svn.apache.org/r1476996
Log:
Fix some ISEs that were appearing in the logs.

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
    tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.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=1476996&r1=1476995&r2=1476996&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties Mon 
Apr 29 12:28:00 2013
@@ -33,6 +33,7 @@ wsFrame.invalidUtf8Close=A WebSocket clo
 wsFrame.noContinuation=A new message was started when a continuation frame was 
expected
 wsFrame.notMasked=The client frame was not masked but all client frames must 
be masked
 wsFrame.oneByteCloseCode=The client sent a close frame with a single byte 
payload which is not valid
+wsFrame.sessionClosed=The client data can not be processed because the session 
has already been closed
 wsFrame.textMessageTooBig=The decoded text message was too big for the output 
buffer and the endpoint does not support partial messages
 wsFrame.wrongRsv=The client frame set the reserved bits to [{0}] which was not 
supported by this endpoint
 

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java?rev=1476996&r1=1476995&r2=1476996&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java Mon Apr 29 
12:28:00 2013
@@ -159,25 +159,32 @@ public abstract class WsFrameBase {
                             sm.getString("wsFrame.noContinuation")));
                 }
             } else {
-                if (opCode == Constants.OPCODE_BINARY) {
-                    // New binary message
-                    textMessage = false;
-                    int size = wsSession.getMaxBinaryMessageBufferSize();
-                    if (size != messageBufferBinary.capacity()) {
-                        messageBufferBinary = ByteBuffer.allocate(size);
-                    }
-                } else if (opCode == Constants.OPCODE_TEXT) {
-                    // New text message
-                    textMessage = true;
-                    int size = wsSession.getMaxTextMessageBufferSize();
-                    if (size != messageBufferText.capacity()) {
-                        messageBufferText = CharBuffer.allocate(size);
+                try {
+                    if (opCode == Constants.OPCODE_BINARY) {
+                        // New binary message
+                        textMessage = false;
+                        int size = wsSession.getMaxBinaryMessageBufferSize();
+                        if (size != messageBufferBinary.capacity()) {
+                            messageBufferBinary = ByteBuffer.allocate(size);
+                        }
+                    } else if (opCode == Constants.OPCODE_TEXT) {
+                        // New text message
+                        textMessage = true;
+                        int size = wsSession.getMaxTextMessageBufferSize();
+                        if (size != messageBufferText.capacity()) {
+                            messageBufferText = CharBuffer.allocate(size);
+                        }
+                    } else {
+                        throw new WsIOException(new CloseReason(
+                                CloseCodes.PROTOCOL_ERROR,
+                                sm.getString("wsFrame.invalidOpCode",
+                                        Integer.valueOf(opCode))));
                     }
-                } else {
+                } catch (IllegalStateException ise) {
+                    // Thrown if the session is already closed
                     throw new WsIOException(new CloseReason(
                             CloseCodes.PROTOCOL_ERROR,
-                            sm.getString("wsFrame.invalidOpCode",
-                                    Integer.valueOf(opCode))));
+                            sm.getString("wsFrame.sessionClosed")));
                 }
             }
             continuationExpected = !fin;



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

Reply via email to