Minimal reproduction project for a regression in Spring Boot 3.5.8 causing NullPointerException in Undertow during test context cleanup.
After upgrading from Spring Boot 3.5.7 to 3.5.8, tests using @DirtiesContext with Undertow fail with:
java.lang.NullPointerException: Cannot invoke "io.undertow.servlet.core.DeploymentImpl.getDeploymentState()" because "this.deployment" is null
at io.undertow.servlet.core.DeploymentManagerImpl.stop(DeploymentManagerImpl.java:615)
at org.springframework.boot.web.embedded.undertow.DeploymentManagerHttpHandlerFactory$DeploymentManagerHandler.close(DeploymentManagerHttpHandlerFactory.java:80)
at org.springframework.boot.web.embedded.undertow.UndertowWebServer.destroy(UndertowWebServer.java:294)
Probably a regression introduced by fix for #48061 (backport of #47141).
The separation of stop() and destroy() in UndertowWebServer causes DeploymentManagerImpl.stop() to be called when deployment is already null.
git clone https://github.com/tschlat/spring-boot-3-5-8-undertow-issue.git
cd spring-boot-3-5-8-undertow-issue
mvn verifyExpected: All tests pass.
Actual:
DirtiesContextIT fails with NullPointerException.
NotDirtiesContextIT succeeds.
- Spring Boot 3.5.8 (works in 3.5.7)
- Undertow as embedded server
@DirtiesContextannotationWebEnvironment.RANDOM_PORT- Complex application context (e.g., Citrus Simulator beans)
Downgrade to Spring Boot 3.5.7:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.7</version>
</parent>