Commit 2a40bd78 authored by Andy Wilkinson's avatar Andy Wilkinson

Register shutdown hook so it can tidy up a partial refresh

Previously, the shutdown hook was only registered once refresh has
completed. If the JVM was shut down during refresh (or after refresh
and before the hook was registered) the hook wouldn't run and the
partially refreshed context would not be cleaned up.

This commit moves the registration of the shutdown hook to before
refresh processing begins. This ensures that the hook is available
to clean up the context if the JVM is shutdown while refresh is in
progress.

Fixes gh-23625
parent f43970e6
......@@ -394,7 +394,6 @@ public class SpringApplication {
}
private void refreshContext(ConfigurableApplicationContext context) {
refresh(context);
if (this.registerShutdownHook) {
try {
context.registerShutdownHook();
......@@ -403,6 +402,7 @@ public class SpringApplication {
// Not allowed in some environments.
}
}
refresh(context);
}
private void configureHeadlessProperty() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment