Author: markt
Date: Fri Sep 20 12:40:39 2013
New Revision: 1524984

URL: http://svn.apache.org/r1524984
Log:
Fix possible false test failure when the session gets closed before the message 
write can complete.

Modified:
    tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java

Modified: 
tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java?rev=1524984&r1=1524983&r2=1524984&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java 
(original)
+++ tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java 
Fri Sep 20 12:40:39 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.tomcat.websocket;
 
+import java.io.IOException;
 import java.net.SocketTimeoutException;
 import java.net.URI;
 import java.nio.ByteBuffer;
@@ -252,11 +253,17 @@ public class TestWsWebSocketContainer ex
         }
 
         wsSession.addMessageHandler(handler);
-        if (isTextMessage) {
-            wsSession.getBasicRemote().sendText(MESSAGE_TEXT_4K);
-        } else {
-            wsSession.getBasicRemote().sendBinary(
-                    ByteBuffer.wrap(MESSAGE_BINARY_4K));
+        try {
+            if (isTextMessage) {
+                wsSession.getBasicRemote().sendText(MESSAGE_TEXT_4K);
+            } else {
+                wsSession.getBasicRemote().sendBinary(
+                        ByteBuffer.wrap(MESSAGE_BINARY_4K));
+            }
+        } catch (IOException ioe) {
+            // Some messages sends are expected to fail. Assertions further on
+            // in this method will check for the correct behaviour so ignore 
any
+            // exception here.
         }
 
         boolean latchResult = handler.getLatch().await(10, TimeUnit.SECONDS);



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to