diff --git a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientTimeoutTest.java b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientTimeoutTest.java index d18e59ad8ea..8cc2a7e70fa 100644 --- a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientTimeoutTest.java +++ b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientTimeoutTest.java @@ -100,7 +100,7 @@ public class ClientTimeoutTest client.setMaxIdleTimeout(timeout); Future connect = client.connect(clientSocket, WSURI.toWebsocket(server.getURI())); - ExecutionException executionException = assertThrows(ExecutionException.class, () -> connect.get(timeout + 200, TimeUnit.MILLISECONDS)); + ExecutionException executionException = assertThrows(ExecutionException.class, () -> connect.get(timeout * 2, TimeUnit.MILLISECONDS)); assertThat(executionException.getCause(), instanceOf(UpgradeException.class)); UpgradeException upgradeException = (UpgradeException)executionException.getCause(); assertThat(upgradeException.getCause(), instanceOf(TimeoutException.class)); @@ -112,10 +112,10 @@ public class ClientTimeoutTest EventSocket clientSocket = new EventSocket(); long timeout = 1000; ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest(); - upgradeRequest.timeout(timeout, TimeUnit.MILLISECONDS); + upgradeRequest.setTimeout(timeout, TimeUnit.MILLISECONDS); Future connect = client.connect(clientSocket, WSURI.toWebsocket(server.getURI()), upgradeRequest); - ExecutionException executionException = assertThrows(ExecutionException.class, () -> connect.get(timeout + 200, TimeUnit.MILLISECONDS)); + ExecutionException executionException = assertThrows(ExecutionException.class, () -> connect.get(timeout * 2, TimeUnit.MILLISECONDS)); assertThat(executionException.getCause(), instanceOf(UpgradeException.class)); UpgradeException upgradeException = (UpgradeException)executionException.getCause(); assertThat(upgradeException.getCause(), instanceOf(TimeoutException.class)); diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java index 854f1022701..0fcbaa43670 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java @@ -185,12 +185,10 @@ public class ClientUpgradeRequest extends UpgradeRequestAdapter * @param timeout the total timeout for the request/response conversation of the WebSocket handshake; * use zero or a negative value to disable the timeout * @param unit the timeout unit - * @return this request object */ - public ClientUpgradeRequest timeout(long timeout, TimeUnit unit) + public void setTimeout(long timeout, TimeUnit unit) { this.timeout = unit.toMillis(timeout); - return this; } /**