mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 20:19:06 +00:00
Upgrade to Jetty 12.1.6
Closes gh-49133
This commit is contained in:
+11
-7
@@ -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;
|
||||
|
||||
+1
-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"
|
||||
|
||||
Reference in New Issue
Block a user