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-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org