You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/05/21 00:28:33 UTC

svn commit: r1484618 - /tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java

Author: markt
Date: Mon May 20 22:28:33 2013
New Revision: 1484618

URL: http://svn.apache.org/r1484618
Log:
Check for EOF in case the server hangs up unexpectedly.

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1484618&r1=1484617&r2=1484618&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Mon May 20 22:28:33 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.tomcat.websocket;
 
+import java.io.EOFException;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -331,7 +332,8 @@ public class WsWebSocketContainer
                 throw new DeploymentException(
                         sm.getString("Sec-WebSocket-Protocol"));
             }
-        } catch (ExecutionException | InterruptedException | SSLException e) {
+        } catch (ExecutionException | InterruptedException | SSLException |
+                EOFException e) {
             throw new DeploymentException(
                     sm.getString("wsWebSocketContainer.httpRequestFailed"), e);
         }
@@ -515,7 +517,7 @@ public class WsWebSocketContainer
      */
     private HandshakeResponse processResponse(ByteBuffer response,
             AsyncChannelWrapper channel) throws InterruptedException,
-            ExecutionException, DeploymentException {
+            ExecutionException, DeploymentException, EOFException {
 
         Map<String,List<String>> headers = new HashMap<>();
 
@@ -524,8 +526,11 @@ public class WsWebSocketContainer
         String line = null;
         while (!readHeaders) {
             // Blocking read
-            Future<Integer> written = channel.read(response);
-            written.get();
+            Future<Integer> read = channel.read(response);
+            Integer bytesRead = read.get();
+            if (bytesRead.intValue() == -1) {
+                throw new EOFException();
+            }
             response.flip();
             while (response.hasRemaining() && !readHeaders) {
                 if (line == null) {



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