Skip to content

Commit 90c656c

Browse files
committed
Merge branch '3.5.x'
Closes gh-47718
2 parents fad9a6e + 1289759 commit 90c656c

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.springframework.boot.jetty.autoconfigure;
1818

1919
import org.eclipse.jetty.util.VirtualThreads;
20-
import org.eclipse.jetty.util.thread.QueuedThreadPool;
20+
import org.eclipse.jetty.util.thread.VirtualThreadPool;
2121

2222
import org.springframework.boot.context.properties.bind.Bindable;
2323
import org.springframework.boot.context.properties.bind.Binder;
@@ -32,6 +32,7 @@
3232
* Activates virtual threads on the {@link ConfigurableJettyWebServerFactory}.
3333
*
3434
* @author Moritz Halbritter
35+
* @author Brian Clozel
3536
* @since 4.0.0
3637
*/
3738
public class JettyVirtualThreadsWebServerFactoryCustomizer
@@ -49,9 +50,9 @@ public JettyVirtualThreadsWebServerFactoryCustomizer(JettyServerProperties jetty
4950
@Override
5051
public void customize(ConfigurableJettyWebServerFactory factory) {
5152
Assert.state(VirtualThreads.areSupported(), "Virtual threads are not supported");
52-
QueuedThreadPool threadPool = JettyThreadPool.create(this.jettyProperties.getThreads());
53-
threadPool.setVirtualThreadsExecutor(VirtualThreads.getNamedVirtualThreadsExecutor("jetty-"));
54-
factory.setThreadPool(threadPool);
53+
VirtualThreadPool virtualThreadPool = new VirtualThreadPool();
54+
virtualThreadPool.setName("jetty-");
55+
factory.setThreadPool(virtualThreadPool);
5556
}
5657

5758
@Override

module/spring-boot-jetty/src/test/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizerTests.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@
1616

1717
package org.springframework.boot.jetty.autoconfigure;
1818

19-
import java.time.Duration;
20-
import java.util.concurrent.Executor;
21-
import java.util.concurrent.atomic.AtomicReference;
22-
23-
import org.awaitility.Awaitility;
24-
import org.eclipse.jetty.util.thread.QueuedThreadPool;
25-
import org.hamcrest.Matchers;
19+
import org.eclipse.jetty.util.thread.VirtualThreadPool;
2620
import org.junit.jupiter.api.Test;
2721
import org.junit.jupiter.api.condition.EnabledForJreRange;
2822
import org.junit.jupiter.api.condition.JRE;
@@ -50,14 +44,9 @@ void shouldConfigureVirtualThreads() {
5044
ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class);
5145
customizer.customize(factory);
5246
then(factory).should().setThreadPool(assertArg((threadPool) -> {
53-
assertThat(threadPool).isInstanceOf(QueuedThreadPool.class);
54-
QueuedThreadPool queuedThreadPool = (QueuedThreadPool) threadPool;
55-
Executor executor = queuedThreadPool.getVirtualThreadsExecutor();
56-
assertThat(executor).isNotNull();
57-
AtomicReference<String> threadName = new AtomicReference<>();
58-
executor.execute(() -> threadName.set(Thread.currentThread().getName()));
59-
Awaitility.await().atMost(Duration.ofSeconds(1)).untilAtomic(threadName, Matchers.notNullValue());
60-
assertThat(threadName.get()).startsWith("jetty-");
47+
assertThat(threadPool).isInstanceOf(VirtualThreadPool.class);
48+
VirtualThreadPool virtualThreadPool = (VirtualThreadPool) threadPool;
49+
assertThat(virtualThreadPool.getName()).isEqualTo("jetty-");
6150
}));
6251
}
6352

0 commit comments

Comments
 (0)