File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
spring-boot-project/spring-boot-autoconfigure/src
main/java/org/springframework/boot/autoconfigure/web/embedded
test/java/org/springframework/boot/autoconfigure/web/embedded Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 1717package org .springframework .boot .autoconfigure .web .embedded ;
1818
1919import io .undertow .Undertow ;
20+ import io .undertow .servlet .api .DeploymentInfo ;
2021import org .apache .catalina .startup .Tomcat ;
2122import org .apache .coyote .UpgradeProtocol ;
2223import org .eclipse .jetty .ee10 .webapp .WebAppContext ;
@@ -110,10 +111,16 @@ public UndertowWebServerFactoryCustomizer undertowWebServerFactoryCustomizer(Env
110111 return new UndertowWebServerFactoryCustomizer (environment , serverProperties );
111112 }
112113
113- @ Bean
114- @ ConditionalOnThreading (Threading .VIRTUAL )
115- UndertowDeploymentInfoCustomizer virtualThreadsUndertowDeploymentInfoCustomizer () {
116- return (deploymentInfo ) -> deploymentInfo .setExecutor (new VirtualThreadTaskExecutor ("undertow-" ));
114+ @ Configuration (proxyBeanMethods = false )
115+ @ ConditionalOnClass (DeploymentInfo .class )
116+ static class UndertowServletWebServerFactoryCustomizerConfiguration {
117+
118+ @ Bean
119+ @ ConditionalOnThreading (Threading .VIRTUAL )
120+ UndertowDeploymentInfoCustomizer virtualThreadsUndertowDeploymentInfoCustomizer () {
121+ return (deploymentInfo ) -> deploymentInfo .setExecutor (new VirtualThreadTaskExecutor ("undertow-" ));
122+ }
123+
117124 }
118125
119126 }
Original file line number Diff line number Diff line change 2323
2424import org .springframework .boot .autoconfigure .AutoConfigurations ;
2525import org .springframework .boot .autoconfigure .web .embedded .EmbeddedWebServerFactoryCustomizerAutoConfiguration .UndertowWebServerFactoryCustomizerConfiguration ;
26+ import org .springframework .boot .test .context .FilteredClassLoader ;
2627import org .springframework .boot .test .context .runner .WebApplicationContextRunner ;
2728import org .springframework .boot .web .embedded .undertow .UndertowDeploymentInfoCustomizer ;
2829import org .springframework .boot .web .servlet .context .AnnotationConfigServletWebApplicationContext ;
@@ -54,4 +55,12 @@ void shouldUseVirtualThreadsIfEnabled() {
5455 });
5556 }
5657
58+ @ Test
59+ @ EnabledForJreRange (min = JRE .JAVA_21 )
60+ void virtualThreadCustomizationBacksOffWithoutUndertowServlet () {
61+ this .contextRunner .withPropertyValues ("spring.threads.virtual.enabled=true" )
62+ .withClassLoader (new FilteredClassLoader ("io.undertow.servlet" ))
63+ .run ((context ) -> assertThat (context ).doesNotHaveBean (UndertowDeploymentInfoCustomizer .class ));
64+ }
65+
5766}
You can’t perform that action at this time.
0 commit comments