Only wait for background preinit to complete when it has started

Closes gh-10362
pull/8753/merge
Andy Wilkinson 7 years ago
parent b602b1da2e
commit 616d11c00a

@ -46,7 +46,8 @@ import org.springframework.http.converter.support.AllEncompassingFormHttpMessage
public class BackgroundPreinitializer
implements ApplicationListener<SpringApplicationEvent> {
private static final AtomicBoolean preinitializationStarted = new AtomicBoolean(false);
private static final AtomicBoolean preinitializationStarted = new AtomicBoolean(
false);
private static final CountDownLatch preinitializationComplete = new CountDownLatch(1);
@ -57,8 +58,9 @@ public class BackgroundPreinitializer
performPreinitialization();
}
}
if (event instanceof ApplicationReadyEvent
|| event instanceof ApplicationFailedEvent) {
if ((event instanceof ApplicationReadyEvent
|| event instanceof ApplicationFailedEvent)
&& preinitializationStarted.get()) {
try {
preinitializationComplete.await();
}

Loading…
Cancel
Save