From 809578cd008d55fbc6cefefa05efadd96f3230f3 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 5 Feb 2026 15:27:30 +0000 Subject: [PATCH] Upgrade to Jetty 12.1.6 Closes gh-49133 --- ...rtualThreadsWebServerFactoryCustomizer.java | 18 +++++++++++------- ...ThreadsWebServerFactoryCustomizerTests.java | 2 +- platform/spring-boot-dependencies/build.gradle | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizer.java b/module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizer.java index 2bf589296a5..820f1d96dc0 100644 --- a/module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizer.java +++ b/module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizer.java @@ -21,7 +21,6 @@ import org.eclipse.jetty.util.thread.VirtualThreadPool; import org.jspecify.annotations.Nullable; import org.springframework.boot.jetty.ConfigurableJettyWebServerFactory; -import org.springframework.boot.jetty.autoconfigure.JettyServerProperties.Threads; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.core.Ordered; import org.springframework.util.Assert; @@ -62,16 +61,21 @@ public class JettyVirtualThreadsWebServerFactoryCustomizer @Override public void customize(ConfigurableJettyWebServerFactory factory) { Assert.state(VirtualThreads.areSupported(), "Virtual threads are not supported"); - VirtualThreadPool virtualThreadPool = new VirtualThreadPool(); + Integer maxTasks = getMaxTasks(); + VirtualThreadPool virtualThreadPool = (maxTasks != null) ? new VirtualThreadPool(maxTasks) + : new VirtualThreadPool(); virtualThreadPool.setName("jetty-"); - if (this.serverProperties != null) { - Threads properties = this.serverProperties.getThreads(); - int maxThreadCount = (properties.getMax() > 0) ? properties.getMax() : 200; - virtualThreadPool.setMaxThreads(maxThreadCount); - } factory.setThreadPool(virtualThreadPool); } + private @Nullable Integer getMaxTasks() { + if (this.serverProperties == null) { + return null; + } + Integer maxThreads = this.serverProperties.getThreads().getMax(); + return (maxThreads > 0) ? maxThreads : null; + } + @Override public int getOrder() { return JettyWebServerFactoryCustomizer.ORDER + 1; diff --git a/module/spring-boot-jetty/src/test/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizerTests.java b/module/spring-boot-jetty/src/test/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizerTests.java index c5d31db9b4e..06e01be448b 100644 --- a/module/spring-boot-jetty/src/test/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizerTests.java +++ b/module/spring-boot-jetty/src/test/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizerTests.java @@ -48,7 +48,7 @@ class JettyVirtualThreadsWebServerFactoryCustomizerTests { assertThat(threadPool).isInstanceOf(VirtualThreadPool.class); VirtualThreadPool virtualThreadPool = (VirtualThreadPool) threadPool; assertThat(virtualThreadPool.getName()).isEqualTo("jetty-"); - assertThat(virtualThreadPool.getMaxThreads()).isEqualTo(100); + assertThat(virtualThreadPool.getMaxConcurrentTasks()).isEqualTo(100); })); } diff --git a/platform/spring-boot-dependencies/build.gradle b/platform/spring-boot-dependencies/build.gradle index e3324f850d5..b8e88252538 100644 --- a/platform/spring-boot-dependencies/build.gradle +++ b/platform/spring-boot-dependencies/build.gradle @@ -1083,7 +1083,7 @@ bom { ] } } - library("Jetty", "12.1.5") { + library("Jetty", "12.1.6") { prohibit { contains ".alpha" because "we don't want alpha dependencies"