Skip to content

SpringApplicationShutdownHandlers do not run in deterministic order #43430

Closed
@betalb

Description

@betalb

Spring Boot version: tested on 3.2.12 and 3.4.0

This issue was mostly resolved in #40178, but one edge case still left.

When app receives SIGTERM during application startup after ApplicationEnvironmentPreparedEvent, but before ApplicationContextInitializedEvent, Log4j2 (and other logging systems) will run shutdown handler in SpringApplicationShutdownHook, i.e. the one that is returned by org.springframework.boot.logging.log4j2.Log4J2LoggingSystem#getShutdownHandler. During shutdown it will try to read some properties (i.e. log4j2.disable.jmx) from SpringEnvironmentPropertySource which still holds reference to underlying environment.

Attaching small repro of this issue: sample-app.tar.gz

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions