Skip to content

Commit e9033a8

Browse files
committed
Merge branch '3.4.x' into 3.5.x
Closes gh-46180
2 parents cf6dd4b + 1c40476 commit e9033a8

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.autoconfigure.web.embedded;
1818

1919
import io.undertow.Undertow;
20+
import io.undertow.servlet.api.DeploymentInfo;
2021
import org.apache.catalina.startup.Tomcat;
2122
import org.apache.coyote.UpgradeProtocol;
2223
import 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
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerConfigurationTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.springframework.boot.autoconfigure.AutoConfigurations;
2525
import org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration.UndertowWebServerFactoryCustomizerConfiguration;
26+
import org.springframework.boot.test.context.FilteredClassLoader;
2627
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
2728
import org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer;
2829
import 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
}

0 commit comments

Comments
 (0)