Upgrade to Jetty 12.1.6

Closes gh-49133
This commit is contained in:
Andy Wilkinson
2026-02-05 17:46:50 +00:00
parent 4a2d2438d6
commit 809578cd00
3 changed files with 13 additions and 9 deletions
@@ -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;
@@ -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);
}));
}
@@ -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"