When repeatedly deploying and undeploying a Spring Boot version 3.1.2 web application (WAR file) in a Tomcat application server one gets java.lang.OutOfMemoryError: Metaspace after 7-8 attempts.
This seems to be caused by the change in org.springframework.boot.SpringApplicationShutdownHook class, which now also registers org.springframework.boot.SpringApplicationShutdownHook.Handlers as a shut-down hook, which was not the case with Spring Boot 2.7 for example.
Comment From: philwebb
It looks like we may have a regression that's re-introduced #27987
Comment From: philwebb
@vazhaa72 Have experienced the same problem with 3.0.x? I'm just wondering when we broke things.
Comment From: vazhaa72
@vazhaa72 Have experienced the same problem with 3.0.x? I'm just wondering when we broke things.
@philwebb , I recompiled our projects with Spring Boot 3.0.0 and could not reproduce the issue. So I assume that a potential regression came in with 3.1.x.
Comment From: wilkinsona
The regression is due to https://github.com/spring-projects/spring-boot/issues/34627. LoggingApplicationListener adds a shutdown handler which now causes the runtime shutdown hook to be added.
@vazhaa72, you can work around the problem by adding logging.register-shutdown-hook=false to application.properties.