Author: markt
Date: Fri Jan 25 13:00:51 2013
New Revision: 1438484

URL: http://svn.apache.org/viewvc?rev=1438484&view=rev
Log:
Fix a handful of i18n TODOs

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
    tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.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=1438484&r1=1438483&r2=1438484&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties Fri 
Jan 25 13:00:51 2013
@@ -37,6 +37,13 @@ wsFrame.wrongRsv=The client frame set th
 
 wsRemoteEndpoint.concurrentMessageSend=Messages may not be send concurrently 
even when using the asynchronous send messages. The client must wait for the 
previous message to complete before sending the next.
 
+wsSession.duplicateHandlerBinary=A binary message handler has already been 
configured
+wsSession.duplicateHandlerPong=A pong message handler has already been 
configured
+wsSession.duplicateHandlerText=A text message handler has already been 
configured
+wsSession.invalidHandlerTypePong=A pong message handler must implement 
MessageHandler.Basic
+wsSession.removeHandlerFailed=Unable to remove the handler [{0}] as it was not 
registered with this session
+wsSession.unknownHandler=Unable to add the message handler [{0}] as it was for 
the unrecognised type [{1}]
+
 wsWebSocketContainer.invalidStatus=The HTTP response from the server [{0}] did 
not permit the HTTP upgrade to WebSocket
 wsWebSocketContainer.maxBuffer=This implementation limits the maximum size of 
a buffer to Integer.MAX_VALUE
 wsWebSocketContainer.pathNoHost=No host was specified in URI

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=1438484&r1=1438483&r2=1438484&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Fri Jan 25 
13:00:51 2013
@@ -39,9 +39,13 @@ import javax.websocket.RemoteEndpoint;
 import javax.websocket.Session;
 import javax.websocket.WebSocketContainer;
 
+import org.apache.tomcat.util.res.StringManager;
+
 public class WsSession implements Session {
 
     private static final Charset UTF8 = Charset.forName("UTF8");
+    private static final StringManager sm =
+            StringManager.getManager(Constants.PACKAGE_NAME);
 
     private final Endpoint localEndpoint;
     private final WsRemoteEndpointBase wsRemoteEndpoint;
@@ -88,30 +92,31 @@ public class WsSession implements Sessio
 
         if (t.equals(String.class)) {
             if (textMessageHandler != null) {
-                // TODO i18n
-                throw new IllegalStateException();
+                throw new IllegalStateException(
+                        sm.getString("wsSession.duplicateHandlerText"));
             }
             textMessageHandler = listener;
         } else if (t.equals(ByteBuffer.class)) {
             if (binaryMessageHandler != null) {
-                // TODO i18n
-                throw new IllegalStateException();
+                throw new IllegalStateException(
+                        sm.getString("wsSession.duplicateHandlerBinary"));
             }
             binaryMessageHandler = listener;
         } else if (t.equals(PongMessage.class)) {
             if (pongMessageHandler != null) {
-                // TODO i18n
-                throw new IllegalStateException();
+                throw new IllegalStateException(
+                        sm.getString("wsSession.duplicateHandlerPong"));
             }
             if (listener instanceof MessageHandler.Basic<?>) {
-                pongMessageHandler = (MessageHandler.Basic<PongMessage>) 
listener;
+                pongMessageHandler =
+                        (MessageHandler.Basic<PongMessage>) listener;
             } else {
-                // TODO i18n
-                throw new IllegalArgumentException();
+                throw new IllegalStateException(
+                        sm.getString("wsSession.invalidHandlerTypePong"));
             }
         } else {
-            // TODO i18n
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException(
+                    sm.getString("wsSession.unknownHandler", listener, t));
         }
     }
 
@@ -144,7 +149,11 @@ public class WsSession implements Sessio
         } else if (listener.equals(pongMessageHandler)) {
             pongMessageHandler = null;
         }
-        // TODO Ignore? ISE?
+
+        // ISE for now. Could swallow this silently / log this if the ISE
+        // becomes a problem
+        throw new IllegalStateException(
+                sm.getString("wsSession.removeHandlerFailed", listener));
     }
 
 



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

Reply via email to