--- 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"));