Skip to content

Commit 616d11c

Browse files
committed
Only wait for background preinit to complete when it has started
Closes gh-10362
1 parent b602b1d commit 616d11c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/BackgroundPreinitializer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
public class BackgroundPreinitializer
4747
implements ApplicationListener<SpringApplicationEvent> {
4848

49-
private static final AtomicBoolean preinitializationStarted = new AtomicBoolean(false);
49+
private static final AtomicBoolean preinitializationStarted = new AtomicBoolean(
50+
false);
5051

5152
private static final CountDownLatch preinitializationComplete = new CountDownLatch(1);
5253

@@ -57,8 +58,9 @@ public void onApplicationEvent(SpringApplicationEvent event) {
5758
performPreinitialization();
5859
}
5960
}
60-
if (event instanceof ApplicationReadyEvent
61-
|| event instanceof ApplicationFailedEvent) {
61+
if ((event instanceof ApplicationReadyEvent
62+
|| event instanceof ApplicationFailedEvent)
63+
&& preinitializationStarted.get()) {
6264
try {
6365
preinitializationComplete.await();
6466
}

0 commit comments

Comments
 (0)