From 74897bc52a8c3524746f604450066c1bc4cac6e0 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 18 Sep 2019 21:25:37 +0200 Subject: [PATCH] Use Reactor's new Schedulers.boundedElastic() Prior to this commit, Spring Framework would use `Schedulers.elastic()` in places where we needed to process blocking tasks in a reactive environment. With reactor/reactor-core#1804, a new `Schedulers.boundedElastic()` scheduler is available and achieves the same goal with added security; it guarantees that resources are bounded. This commit uses that new scheduler in the standard websocket client, since the underlying API is blocking for the connection phase and we need to schedule that off a web server thread. Closes gh-23661 See gh-23665 --- build.gradle | 3 ++- .../web/reactive/socket/client/StandardWebSocketClient.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 4fd4b0dca0..1868e15bed 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ configure(allprojects) { project -> imports { mavenBom "com.fasterxml.jackson:jackson-bom:2.9.9" mavenBom "io.netty:netty-bom:4.1.39.Final" - mavenBom "io.projectreactor:reactor-bom:Dysprosium-RC1" + mavenBom "io.projectreactor:reactor-bom:Dysprosium-BUILD-SNAPSHOT" mavenBom "org.eclipse.jetty:jetty-bom:9.4.20.v20190813" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.50" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.1" @@ -297,6 +297,7 @@ configure(allprojects) { project -> mavenCentral() maven { url "https://repo.spring.io/libs-release" } maven { url "https://repo.spring.io/milestone" } // Reactor + maven { url "https://repo.spring.io/snapshot" } // Reactor } } configurations.all { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/StandardWebSocketClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/StandardWebSocketClient.java index 474c82d073..baffed71ea 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/StandardWebSocketClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/StandardWebSocketClient.java @@ -109,7 +109,7 @@ public class StandardWebSocketClient implements WebSocketClient { ClientEndpointConfig config = createEndpointConfig(configurator, protocols); return this.webSocketContainer.connectToServer(endpoint, config, url); }) - .subscribeOn(Schedulers.elastic()) // connectToServer is blocking + .subscribeOn(Schedulers.boundedElastic()) // connectToServer is blocking .then(completionMono); }