diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/BackgroundPreinitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/BackgroundPreinitializer.java index b224582db4..cceff6b59b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/BackgroundPreinitializer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/BackgroundPreinitializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,11 +63,19 @@ public class BackgroundPreinitializer implements ApplicationListener 1; + } + @Override public void onApplicationEvent(SpringApplicationEvent event) { - if (!Boolean.getBoolean(IGNORE_BACKGROUNDPREINITIALIZER_PROPERTY_NAME) - && event instanceof ApplicationStartingEvent && multipleProcessors() - && preinitializationStarted.compareAndSet(false, true)) { + if (!ENABLED) { + return; + } + if (event instanceof ApplicationStartingEvent && preinitializationStarted.compareAndSet(false, true)) { performPreinitialization(); } if ((event instanceof ApplicationReadyEvent || event instanceof ApplicationFailedEvent) @@ -81,10 +89,6 @@ public class BackgroundPreinitializer implements ApplicationListener 1; - } - private void performPreinitialization() { try { Thread thread = new Thread(new Runnable() {