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
This commit is contained in:
Brian Clozel
2019-09-18 21:25:37 +02:00
parent 90b5e6ab48
commit 74897bc52a
2 changed files with 3 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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);
}