From 1e342e4dbff7d5edef23356daa304e05b40d4147 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 25 Jun 2014 08:40:27 -0400 Subject: [PATCH] Use SimpleAsyncTaskExecutor in WebSocketClient impls JettyWebsocketClient and StandardWebSocketClient now use the SimpleAsyncTaskExecutor by default to ensure non-blocking connect. --- .../web/socket/client/jetty/JettyWebSocketClient.java | 8 +++++--- .../socket/client/standard/StandardWebSocketClient.java | 8 +++++--- 2 files changed, 10 insertions(+), 6 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 3bc7a965ec..485c920d52 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 @@ -28,6 +28,7 @@ import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.springframework.context.SmartLifecycle; import org.springframework.core.task.AsyncListenableTaskExecutor; +import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.core.task.TaskExecutor; import org.springframework.http.HttpHeaders; import org.springframework.util.concurrent.ListenableFuture; @@ -59,7 +60,7 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Sma private final Object lifecycleMonitor = new Object(); - private AsyncListenableTaskExecutor taskExecutor; + private AsyncListenableTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); /** @@ -81,9 +82,10 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Sma /** * Set an {@link AsyncListenableTaskExecutor} to use when opening connections. - * - *

If this property is not configured, calls to any of the + * If this property is set to {@code null}, calls to any of the * {@code doHandshake} methods will block until the connection is established. + * + *

By default an instance of {@code SimpleAsyncTaskExecutor} is used. */ public void setTaskExecutor(AsyncListenableTaskExecutor taskExecutor) { this.taskExecutor = taskExecutor; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java index 001a790542..2addd49ed2 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java @@ -34,6 +34,7 @@ import javax.websocket.HandshakeResponse; import javax.websocket.WebSocketContainer; import org.springframework.core.task.AsyncListenableTaskExecutor; +import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.core.task.TaskExecutor; import org.springframework.http.HttpHeaders; import org.springframework.lang.UsesJava7; @@ -59,7 +60,7 @@ public class StandardWebSocketClient extends AbstractWebSocketClient { private final WebSocketContainer webSocketContainer; - private AsyncListenableTaskExecutor taskExecutor; + private AsyncListenableTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); /** @@ -86,9 +87,10 @@ public class StandardWebSocketClient extends AbstractWebSocketClient { /** * Set an {@link AsyncListenableTaskExecutor} to use when opening connections. - * - *

If this property is not configured, calls to any of the + * If this property is set to {@code null}, calls to any of the * {@code doHandshake} methods will block until the connection is established. + * + *

By default an instance of {@code SimpleAsyncTaskExecutor} is used. */ public void setTaskExecutor(AsyncListenableTaskExecutor taskExecutor) { this.taskExecutor = taskExecutor;