Browse Source

Upgrade to Jetty 12.1.6

Closes gh-49133
pull/48957/head
Andy Wilkinson 2 months ago
parent
commit
809578cd00
  1. 18
      module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizer.java
  2. 2
      module/spring-boot-jetty/src/test/java/org/springframework/boot/jetty/autoconfigure/JettyVirtualThreadsWebServerFactoryCustomizerTests.java
  3. 2
      platform/spring-boot-dependencies/build.gradle

18
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; @@ -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 @@ -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;

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

@ -48,7 +48,7 @@ class JettyVirtualThreadsWebServerFactoryCustomizerTests { @@ -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);
}));
}

2
platform/spring-boot-dependencies/build.gradle

@ -1083,7 +1083,7 @@ bom { @@ -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"

Loading…
Cancel
Save