Author: markt
Date: Wed Oct 2 09:03:49 2013
New Revision: 1528384
URL: http://svn.apache.org/r1528384
Log:
Swallow exception when writing to a closed client
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1528383
Modified:
tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java?rev=1528384&r1=1528383&r2=1528384&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java
(original)
+++
tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java
Wed Oct 2 09:03:49 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: [email protected]
For additional commands, e-mail: [email protected]