Author: markt
Date: Wed Nov 25 11:30:17 2015
New Revision: 1716358
URL: http://svn.apache.org/viewvc?rev=1716358&view=rev
Log:
Additional fix for BZ58624 based on analysis of 8.0.x failure mode
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1716358&r1=1716357&r2=1716358&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Wed Nov 25
11:30:17 2015
@@ -647,7 +647,24 @@ public class WsSession implements Sessio
* {@link FutureToSendHandler} completes.
*/
protected void registerFuture(FutureToSendHandler f2sh) {
- futures.put(f2sh, f2sh);
+ boolean fail = false;
+ synchronized (stateLock) {
+ // If the session has already been closed the any registered
futures
+ // will have been processed so the failure result for this future
+ // needs to be set here.
+ if (state == State.OPEN) {
+ futures.put(f2sh, f2sh);
+ } else {
+ // Construct the exception outside of the sync block
+ fail = true;
+ }
+ }
+
+ if (fail) {
+ IOException ioe = new
IOException(sm.getString("wsSession.messageFailed"));
+ SendResult sr = new SendResult(ioe);
+ f2sh.onResult(sr);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]