Author: markt
Date: Thu Jul 11 16:14:59 2013
New Revision: 1502265

URL: http://svn.apache.org/r1502265
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55238
Avoid possible NPE.
Patch by Niki Dokovski.
Also added a check to onTimeout() to save creating an Exception unnecessarily

Modified:
    
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java

Modified: 
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java?rev=1502265&r1=1502264&r2=1502265&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
 (original)
+++ 
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
 Thu Jul 11 16:14:59 2013
@@ -142,7 +142,9 @@ public class WsRemoteEndpointImplServer 
 
 
     protected void onTimeout() {
-        clearHandler(new SocketTimeoutException());
+        if (handler != null) {
+            clearHandler(new SocketTimeoutException());
+        }
         close();
     }
 
@@ -150,10 +152,12 @@ public class WsRemoteEndpointImplServer 
     private void clearHandler(Throwable t) {
         SendHandler sh = handler;
         handler = null;
-        if (t == null) {
-            sh.onResult(new SendResult());
-        } else {
-            sh.onResult(new SendResult(t));
+        if (sh != null) {
+            if (t == null) {
+                sh.onResult(new SendResult());
+            } else {
+                sh.onResult(new SendResult(t));
+            }
         }
     }
 }



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

Reply via email to