Ensure there is only one shutdown hook

The effect of not doing this is not often noticeable, but you sometimes
get a race condition between a context and its parent closing in different
threads without it.
This commit is contained in:
Dave Syer
2015-06-04 08:53:14 +01:00
parent 6d4248bbcd
commit 5d7f18f91f

View File

@@ -54,7 +54,7 @@ import org.springframework.util.StringUtils;
*/
public class BootstrapApplicationListener implements
ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered {
public static final String BOOTSTRAP_PROPERTY_SOURCE_NAME = "bootstrap";
public static final int DEFAULT_ORDER = Ordered.HIGHEST_PRECEDENCE + 5;
@@ -141,6 +141,7 @@ public class BootstrapApplicationListener implements
}
}
if (!installed) {
application.setRegisterShutdownHook(false);
application.addInitializers(new AncestorInitializer(context));
}