tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1528383 - /tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java
Date Wed, 02 Oct 2013 09:03:02 GMT
Author: markt
Date: Wed Oct  2 09:03:02 2013
New Revision: 1528383

URL: http://svn.apache.org/r1528383
Log:
Swallow exception when writing to a closed client

Modified:
    tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java

Modified: tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java?rev=1528383&r1=1528382&r2=1528383&view=diff
==============================================================================
--- tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java (original)
+++ tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java Wed Oct
 2 09:03:02 2013
@@ -79,7 +79,15 @@ public class SnakeTimer {
 
     protected static void broadcast(String message) {
         for (Snake snake : SnakeTimer.getSnakes()) {
-            snake.sendMessage(message);
+            try {
+                snake.sendMessage(message);
+            } catch (IllegalStateException ise) {
+                // An ISE can occur if an attempt is made to write to a
+                // WebSocket connection after it has been closed. The
+                // alternative to catching this exception is to synchronise
+                // the writes to the clients along with the addSnake() and
+                // removeSnake() methods that are already synchronised.
+            }
         }
     }
 



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


Mime
View raw message