Description:
After upgrading from Spring Boot 3.5.7 to 3.5.8, tests using @DirtiesContext with Undertow as embedded server fail with a NullPointerException during context cleanup.
Affected versions:
Spring Boot 3.5.8 (works in 3.5.7)
Undertow 2.3.20.Final
Root Cause Analysis:
This appears to be a regression introduced by the fix for #48061 (backport of #47141). The separation of stop() and destroy() methods in UndertowWebServer causes DeploymentManagerImpl.stop() to be called when deployment is already null.
The following public project can be used to reproduce the issue:
https://github.com/tschlat/spring-boot-3-5-8-undertow-issue