From 905e3c1f9f429afaf582cb8cb774fa15e6d3f4fc Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 14 Nov 2019 17:36:37 +0000 Subject: [PATCH] Avoid indefinite wait in JettyWebSocketClient Closes gh-23994 --- .../web/socket/client/jetty/JettyWebSocketClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java index 459e2562248a..4c8b2d37426a 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; @@ -155,7 +156,7 @@ public ListenableFuture doHandshakeInternal(WebSocketHandler w Callable connectTask = () -> { Future future = this.client.connect(listener, uri, request); - future.get(); + future.get(this.client.getConnectTimeout() + 2000, TimeUnit.MILLISECONDS); return wsSession; };