Author: markt
Date: Thu Jan 24 11:09:39 2013
New Revision: 1437956

URL: http://svn.apache.org/viewvc?rev=1437956&view=rev
Log:
Fix some exception handling TODOs

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
    tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties?rev=1437956&r1=1437955&r2=1437956&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties Thu 
Jan 24 11:09:39 2013
@@ -38,4 +38,5 @@ wsRemoteEndpoint.concurrentMessageSend=M
 
 wsWebSocketContainer.invalidStatus=The HTTP response from the server [{0}] did 
not permit the HTTP upgrade to WebSocket
 wsWebSocketContainer.pathNoHost=No host was specified in URI
-wsWebSocketContainer.pathWrongScheme=The scheme [{0}] is not supported
\ No newline at end of file
+wsWebSocketContainer.pathWrongScheme=The scheme [{0}] is not supported
+wsWebSocketContainer.endpointCreateFail=Failed to create a local endpoint of 
type [{0}]
\ No newline at end of file

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java?rev=1437956&r1=1437955&r2=1437956&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java Thu Jan 24 
11:09:39 2013
@@ -31,13 +31,17 @@ public class WsFrameClient extends WsFra
     private final CompletionHandler<Integer,Void> handler;
 
     public WsFrameClient(ByteBuffer response, AsynchronousSocketChannel 
channel,
-            WsSession wsSession) throws IOException {
+            WsSession wsSession) {
         super(wsSession);
         this.response = response;
         this.channel = channel;
         this.handler = new WsFrameClientCompletionHandler();
 
-        processSocketRead();
+        try {
+            processSocketRead();
+        } catch (IOException e) {
+            close(e);
+        }
     }
 
 
@@ -63,6 +67,17 @@ public class WsFrameClient extends WsFra
     }
 
 
+    private final void close(Throwable t) {
+        CloseReason cr = new CloseReason(
+                CloseCodes.CLOSED_ABNORMALLY, t.getMessage());
+        try {
+            wsSession.close(cr);
+        } catch (IOException ignore) {
+            // Ignore
+        }
+    }
+
+
     @Override
     protected boolean isMasked() {
         // Data is from the server so it is not masked
@@ -87,15 +102,5 @@ public class WsFrameClient extends WsFra
         public void failed(Throwable exc, Void attachment) {
             close(exc);
         }
-
-        private final void close(Throwable t) {
-            CloseReason cr = new CloseReason(
-                    CloseCodes.CLOSED_ABNORMALLY, t.getMessage());
-            try {
-                wsSession.close(cr);
-            } catch (IOException ignore) {
-                // Ignore
-            }
-        }
     }
 }

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=1437956&r1=1437955&r2=1437956&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Thu 
Jan 24 11:09:39 2013
@@ -138,21 +138,18 @@ public class WsWebSocketContainer implem
         try {
             endpoint = clazz.newInstance();
         } catch (InstantiationException | IllegalAccessException e) {
-            // TODO i18n
-            throw new DeploymentException("TDB", e);
+            throw new DeploymentException(sm.getString(
+                    "wsWebSocketContainer.endpointCreateFail", 
clazz.getName()),
+                    e);
         }
         WsSession wsSession = new WsSession(endpoint, wsRemoteEndpointClient);
 
         endpoint.onOpen(wsSession, clientEndpointConfiguration);
 
-        try {
-            // Object creation will trigger input processing
-            @SuppressWarnings("unused")
-            WsFrameClient wsFrameClient =
-                    new WsFrameClient(response, channel, wsSession);
-        } catch (IOException e) {
-            throw new DeploymentException("", e);
-        }
+        // Object creation will trigger input processing
+        @SuppressWarnings("unused")
+        WsFrameClient wsFrameClient =
+                new WsFrameClient(response, channel, wsSession);
 
         return wsSession;
     }



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

Reply via email to