Author: kkolinko
Date: Sun Oct 19 18:38:34 2014
New Revision: 1632968
URL: http://svn.apache.org/r1632968
Log:
Further improve processing of null arguments in remote endpoint (followup to
r1632625):
1) Document IllegalArgumentException in javadoc
2) Handle null arguments in sendObject() methods to throw
IllegalArgumentException instead of NPE.
It is merge of r1632965 from tomcat/trunk.
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/java/javax/websocket/PongMessage.java
tomcat/tc7.0.x/trunk/java/javax/websocket/RemoteEndpoint.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1632965
Modified: tomcat/tc7.0.x/trunk/java/javax/websocket/PongMessage.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/websocket/PongMessage.java?rev=1632968&r1=1632967&r2=1632968&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/javax/websocket/PongMessage.java (original)
+++ tomcat/tc7.0.x/trunk/java/javax/websocket/PongMessage.java Sun Oct 19
18:38:34 2014
@@ -24,7 +24,7 @@ import java.nio.ByteBuffer;
*/
public interface PongMessage {
/**
- * Get the payload of the Pong message..
+ * Get the payload of the Pong message.
*
* @return The payload of the Pong message.
*/
Modified: tomcat/tc7.0.x/trunk/java/javax/websocket/RemoteEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/websocket/RemoteEndpoint.java?rev=1632968&r1=1632967&r2=1632968&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/javax/websocket/RemoteEndpoint.java (original)
+++ tomcat/tc7.0.x/trunk/java/javax/websocket/RemoteEndpoint.java Sun Oct 19
18:38:34 2014
@@ -68,6 +68,7 @@ public interface RemoteEndpoint {
* when the message has been sent.
* @param data The text message to send
* @return A Future that signals when the message has been sent.
+ * @throws IllegalArgumentException if {@code data} is {@code null}.
*/
Future<Void> sendBinary(ByteBuffer data);
@@ -77,11 +78,29 @@ public interface RemoteEndpoint {
* @param data The text message to send
* @param completion Used to signal to the client when the message
has
* been sent
+ * @throws IllegalArgumentException if {@code data} or {@code
completion}
+ * is {@code null}.
*/
void sendBinary(ByteBuffer data, SendHandler completion);
+ /**
+ * Encodes object as a message and sends it asynchronously, using the
+ * Future to signal to the client when the message has been sent.
+ * @param obj The object to be sent.
+ * @return A Future that signals when the message has been sent.
+ * @throws IllegalArgumentException if {@code obj} is {@code null}.
+ */
Future<Void> sendObject(Object obj);
+ /**
+ * Encodes object as a message and sends it asynchronously, using the
+ * SendHandler to signal to the client when the message has been sent.
+ * @param obj The object to be sent.
+ * @param completion Used to signal to the client when the message
has
+ * been sent
+ * @throws IllegalArgumentException if {@code obj} or
+ * {@code completion} is {@code null}.
+ */
void sendObject(Object obj, SendHandler completion);
}
@@ -91,6 +110,7 @@ public interface RemoteEndpoint {
/**
* Send the message, blocking until the message is sent.
* @param text The text message to send.
+ * @throws IllegalArgumentException if {@code text} is {@code null}.
* @throws IOException if an I/O error occurs during the sending of the
* message.
*/
@@ -99,6 +119,7 @@ public interface RemoteEndpoint {
/**
* Send the message, blocking until the message is sent.
* @param data The binary message to send
+ * @throws IllegalArgumentException if {@code data} is {@code null}.
* @throws IOException if an I/O error occurs during the sending of the
* message.
*/
@@ -112,6 +133,7 @@ public interface RemoteEndpoint {
* @param fragment The partial message to send
* @param isLast <code>true</code> if this is the last part of the
* message, otherwise <code>false</code>
+ * @throws IllegalArgumentException if {@code fragment} is {@code
null}.
* @throws IOException if an I/O error occurs during the sending of the
* message.
*/
@@ -125,6 +147,8 @@ public interface RemoteEndpoint {
* @param partialByte The partial message to send
* @param isLast <code>true</code> if this is the last part of
the
* message, otherwise <code>false</code>
+ * @throws IllegalArgumentException if {@code partialByte} is
+ * {@code null}.
* @throws IOException if an I/O error occurs during the sending of the
* message.
*/
@@ -134,7 +158,16 @@ public interface RemoteEndpoint {
Writer getSendWriter() throws IOException;
- void sendObject(Object o) throws IOException, EncodeException;
+ /**
+ * Encodes object as a message and sends it to the remote endpoint.
+ * @param data The object to be sent.
+ * @throws EncodeException if there was a problem encoding the
+ * {@code data} object as a websocket message.
+ * @throws IllegalArgumentException if {@code data} is {@code null}.
+ * @throws IOException if an I/O error occurs during the sending of the
+ * message.
+ */
+ void sendObject(Object data) throws IOException, EncodeException;
}
/**
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java?rev=1632968&r1=1632967&r2=1632968&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
Sun Oct 19 18:38:34 2014
@@ -533,6 +533,13 @@ public abstract class WsRemoteEndpointIm
@SuppressWarnings({"unchecked", "rawtypes"})
public void sendObjectByCompletion(Object obj, SendHandler completion) {
+ if (obj == null) {
+ throw new
IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullData"));
+ }
+ if (completion == null) {
+ throw new
IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullHandler"));
+ }
+
if (Util.isPrimitive(obj.getClass())) {
String msg = obj.toString();
sendStringByCompletion(msg, completion);
Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1632968&r1=1632967&r2=1632968&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Sun Oct 19 18:38:34 2014
@@ -386,7 +386,7 @@
Fix client subprotocol handling. (remm)
</fix>
<fix>
- Add null checks for arguments in remote endpoint. (remm)
+ Add null checks for arguments in remote endpoint. (remm/kkolinko)
</fix>
</changelog>
</subsection>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]