Author: remm
Date: Fri Oct 17 16:22:43 2014
New Revision: 1632625

URL: http://svn.apache.org/r1632625
Log:
Add null checks for arguments in remote endpoint.

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
    tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.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=1632625&r1=1632624&r2=1632625&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties Fri 
Oct 17 16:22:43 2014
@@ -74,6 +74,8 @@ wsRemoteEndpoint.flushOnCloseFailed=Flus
 wsRemoteEndpoint.invalidEncoder=The specified encoder of type [{0}] could not 
be instantiated
 wsRemoteEndpoint.noEncoder=No encoder specified for object of class [{0}]
 wsRemoteEndpoint.wrongState=The remote endpoint was in state [{0}] which is an 
invalid state for called method
+wsRemoteEndpoint.nullData=Invalid null data argument
+wsRemoteEndpoint.nullHandler=Invalid null handler argument
 
 # Note the following message is used as a close reason in a WebSocket control
 # frame and therefore must be 123 bytes (not characters) or less in length.

Modified: 
tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java?rev=1632625&r1=1632624&r2=1632625&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java 
Fri Oct 17 16:22:43 2014
@@ -125,6 +125,9 @@ public abstract class WsRemoteEndpointIm
 
 
     public void sendBytes(ByteBuffer data) throws IOException {
+        if (data == null) {
+            throw new 
IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullData"));
+        }
         stateMachine.binaryStart();
         startMessageBlock(Constants.OPCODE_BINARY, data, true);
         stateMachine.complete(true);
@@ -139,6 +142,12 @@ public abstract class WsRemoteEndpointIm
 
 
     public void sendBytesByCompletion(ByteBuffer data, SendHandler handler) {
+        if (data == null) {
+            throw new 
IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullData"));
+        }
+        if (handler == null) {
+            throw new 
IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullHandler"));
+        }
         StateUpdateSendHandler sush = new StateUpdateSendHandler(handler);
         stateMachine.binaryStart();
         startMessage(Constants.OPCODE_BINARY, data, true, sush);
@@ -147,6 +156,9 @@ public abstract class WsRemoteEndpointIm
 
     public void sendPartialBytes(ByteBuffer partialByte, boolean last)
             throws IOException {
+        if (partialByte == null) {
+            throw new 
IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullData"));
+        }
         stateMachine.binaryPartialStart();
         startMessageBlock(Constants.OPCODE_BINARY, partialByte, last);
         stateMachine.complete(last);
@@ -168,6 +180,9 @@ public abstract class WsRemoteEndpointIm
 
 
     public void sendString(String text) throws IOException {
+        if (text == null) {
+            throw new 
IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullData"));
+        }
         stateMachine.textStart();
         sendPartialString(CharBuffer.wrap(text), true);
     }
@@ -181,6 +196,12 @@ public abstract class WsRemoteEndpointIm
 
 
     public void sendStringByCompletion(String text, SendHandler handler) {
+        if (text == null) {
+            throw new 
IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullData"));
+        }
+        if (handler == null) {
+            throw new 
IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullHandler"));
+        }
         stateMachine.textStart();
         TextMessageSendHandler tmsh = new TextMessageSendHandler(handler,
                 CharBuffer.wrap(text), true, encoder, encoderBuffer, this);
@@ -191,6 +212,9 @@ public abstract class WsRemoteEndpointIm
 
     public void sendPartialString(String fragment, boolean isLast)
             throws IOException {
+        if (fragment == null) {
+            throw new 
IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullData"));
+        }
         stateMachine.textPartialStart();
         sendPartialString(CharBuffer.wrap(fragment), isLast);
     }



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

Reply via email to