Make Servlet-specific customization back off without undertow-servlet
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run Details
Build and Deploy Snapshot / Trigger Docs Build (push) Blocked by required conditions Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:windows-latest name:Windows]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:21], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:21], map[id:windows-latest name:Windows]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:24], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:24], map[id:windows-latest name:Windows]) (push) Waiting to run Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:false version:17]) (push) Waiting to run Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:true version:21]) (push) Waiting to run Details

Closes gh-46178
This commit is contained in:
Andy Wilkinson 2025-06-23 20:31:24 +01:00
parent 2128a84492
commit 1c404767c4
2 changed files with 20 additions and 4 deletions

View File

@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.web.embedded; package org.springframework.boot.autoconfigure.web.embedded;
import io.undertow.Undertow; import io.undertow.Undertow;
import io.undertow.servlet.api.DeploymentInfo;
import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.Tomcat;
import org.apache.coyote.UpgradeProtocol; import org.apache.coyote.UpgradeProtocol;
import org.eclipse.jetty.ee10.webapp.WebAppContext; import org.eclipse.jetty.ee10.webapp.WebAppContext;
@ -110,10 +111,16 @@ public class EmbeddedWebServerFactoryCustomizerAutoConfiguration {
return new UndertowWebServerFactoryCustomizer(environment, serverProperties); return new UndertowWebServerFactoryCustomizer(environment, serverProperties);
} }
@Bean @Configuration(proxyBeanMethods = false)
@ConditionalOnThreading(Threading.VIRTUAL) @ConditionalOnClass(DeploymentInfo.class)
UndertowDeploymentInfoCustomizer virtualThreadsUndertowDeploymentInfoCustomizer() { static class UndertowServletWebServerFactoryCustomizerConfiguration {
return (deploymentInfo) -> deploymentInfo.setExecutor(new VirtualThreadTaskExecutor("undertow-"));
@Bean
@ConditionalOnThreading(Threading.VIRTUAL)
UndertowDeploymentInfoCustomizer virtualThreadsUndertowDeploymentInfoCustomizer() {
return (deploymentInfo) -> deploymentInfo.setExecutor(new VirtualThreadTaskExecutor("undertow-"));
}
} }
} }

View File

@ -23,6 +23,7 @@ import org.junit.jupiter.api.condition.JRE;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration.UndertowWebServerFactoryCustomizerConfiguration; import org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration.UndertowWebServerFactoryCustomizerConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer; import org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext; import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;
@ -54,4 +55,12 @@ class UndertowWebServerFactoryCustomizerConfigurationTests {
}); });
} }
@Test
@EnabledForJreRange(min = JRE.JAVA_21)
void virtualThreadCustomizationBacksOffWithoutUndertowServlet() {
this.contextRunner.withPropertyValues("spring.threads.virtual.enabled=true")
.withClassLoader(new FilteredClassLoader("io.undertow.servlet"))
.run((context) -> assertThat(context).doesNotHaveBean(UndertowDeploymentInfoCustomizer.class));
}
} }