# HG changeset patch # User prappo # Date 1521712107 0 # Node ID 10fcbe13cd195ff02064e8a4ca141d2e7c381d52 # Parent 245debd8398a07fd2ab5db19b5fb6fc4cd3d74db http-client-branch: (WebSocket) from IOE to IAE in sendClose with bad reason diff -r 245debd8398a -r 10fcbe13cd19 src/java.net.http/share/classes/java/net/http/WebSocket.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: * * *

Unless the {@code CompletableFuture} returned from this method diff -r 245debd8398a -r 10fcbe13cd19 src/java.net.http/share/classes/jdk/internal/net/http/websocket/WebSocketImpl.java --- 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 { diff -r 245debd8398a -r 10fcbe13cd19 test/jdk/java/net/httpclient/websocket/WebSocketTest.java --- 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"));