Only close context that is active
Previously, SpringApplicationShutdownHook would call close() on any registered application context even if it wasn't active as it had already been closed. This could lead to deadlock if the context was closed and System.exit was called during application context refresh. This commit updates SpringApplicationShutdownHook so that it only calls close() on active contexts. This prevents deadlock as it avoids trying to sychronize on the context's startupShutdownMonitor on the shutdown hook thread while it's still held on the main thread which called System.exit and is waiting for all of the shutdown hooks to complete. Fixes gh-27049
Showing
Please register or sign in to comment