http-client-branch: (WebSocket) from IOE to IAE in sendClose with bad reason http-client-branch
authorprappo
Thu, 22 Mar 2018 09:48:27 +0000
branchhttp-client-branch
changeset 56341 10fcbe13cd19
parent 56340 245debd8398a
child 56342 5c2ea761455b
http-client-branch: (WebSocket) from IOE to IAE in sendClose with bad reason
src/java.net.http/share/classes/java/net/http/WebSocket.java
src/java.net.http/share/classes/jdk/internal/net/http/websocket/WebSocketImpl.java
test/jdk/java/net/httpclient/websocket/WebSocketTest.java
--- a/src/java.net.http/share/classes/java/net/http/WebSocket.java	Wed Mar 21 19:18:59 2018 +0000
+++ b/src/java.net.http/share/classes/java/net/http/WebSocket.java	Thu Mar 22 09:48:27 2018 +0000
@@ -611,10 +611,10 @@
      * complete exceptionally with:
      * <ul>
      * <li> {@link IllegalArgumentException} -
-     *          if {@code statusCode} is illegal
+     *           if {@code statusCode} is illegal, or
+     *           if {@code reason} is illegal
      * <li> {@link IOException} -
-     *          if an I/O error occurs, or if the output is closed,
-     *          or {@code reason} is illegal
+     *          if an I/O error occurs, or if the output is closed
      * </ul>
      *
      * <p> Unless the {@code CompletableFuture} returned from this method
--- a/src/java.net.http/share/classes/jdk/internal/net/http/websocket/WebSocketImpl.java	Wed Mar 21 19:18:59 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/websocket/WebSocketImpl.java	Thu Mar 22 09:48:27 2018 +0000
@@ -292,7 +292,7 @@
         if (!isLegalToSendFromClient(statusCode)) {
             result = failedFuture(new IllegalArgumentException("statusCode"));
         } else if (!isLegalReason(reason)) {
-            result = failedFuture(new IOException("reason"));
+            result = failedFuture(new IllegalArgumentException("reason"));
         } else if (!outputClosed.compareAndSet(false, true)){
             result = failedFuture(new IOException("Output closed"));
         } else {
--- a/test/jdk/java/net/httpclient/websocket/WebSocketTest.java	Wed Mar 21 19:18:59 2018 +0000
+++ b/test/jdk/java/net/httpclient/websocket/WebSocketTest.java	Thu Mar 22 09:48:27 2018 +0000
@@ -95,14 +95,14 @@
         assertFails(IOE, webSocket.sendText(Support.malformedString(), true));
         assertFails(IOE, webSocket.sendText(Support.malformedString(), false));
 
-        assertFails(IOE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(124)));
-        assertFails(IOE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(125)));
-        assertFails(IOE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(128)));
-        assertFails(IOE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(256)));
-        assertFails(IOE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(257)));
-        assertFails(IOE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWith2NBytes((123 / 2) + 1)));
-        assertFails(IOE, webSocket.sendClose(NORMAL_CLOSURE, Support.malformedString()));
-        assertFails(IOE, webSocket.sendClose(NORMAL_CLOSURE, Support.incompleteString()));
+        assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(124)));
+        assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(125)));
+        assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(128)));
+        assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(256)));
+        assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(257)));
+        assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWith2NBytes((123 / 2) + 1)));
+        assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.malformedString()));
+        assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.incompleteString()));
 
         assertFails(IAE, webSocket.sendClose(-2, "a reason"));
         assertFails(IAE, webSocket.sendClose(-1, "a reason"));