Skip to content

Commit 0a157fa

Browse files
committed
Polishing (backported from 6.2.x)
1 parent 2548d44 commit 0a157fa

File tree

2 files changed

+52
-29
lines changed

2 files changed

+52
-29
lines changed

spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,7 +61,8 @@
6161
* interactions on a {@link org.springframework.context.ConfigurableApplicationContext}.
6262
*
6363
* <p>As of 6.1, this also includes support for JVM checkpoint/restore (Project CRaC)
64-
* when the {@code org.crac:crac} dependency on the classpath.
64+
* when the {@code org.crac:crac} dependency is on the classpath. All running beans
65+
* will get stopped and restarted according to the CRaC checkpoint/restore callbacks.
6566
*
6667
* @author Mark Fisher
6768
* @author Juergen Hoeller
@@ -379,7 +380,7 @@ else if (bean instanceof SmartLifecycle) {
379380
}
380381

381382

382-
// overridable hooks
383+
// Overridable hooks
383384

384385
/**
385386
* Retrieve all applicable Lifecycle beans: all singletons that have already been created,
@@ -493,11 +494,13 @@ else if (member.bean instanceof SmartLifecycle) {
493494
}
494495
}
495496
try {
496-
latch.await(this.timeout, TimeUnit.MILLISECONDS);
497-
if (latch.getCount() > 0 && !countDownBeanNames.isEmpty() && logger.isInfoEnabled()) {
498-
logger.info("Shutdown phase " + this.phase + " ends with " + countDownBeanNames.size() +
499-
" bean" + (countDownBeanNames.size() > 1 ? "s" : "") +
500-
" still running after timeout of " + this.timeout + "ms: " + countDownBeanNames);
497+
if (!latch.await(this.timeout, TimeUnit.MILLISECONDS)) {
498+
// Count is still >0 after timeout
499+
if (!countDownBeanNames.isEmpty() && logger.isInfoEnabled()) {
500+
logger.info("Shutdown phase " + this.phase + " ends with " + countDownBeanNames.size() +
501+
" bean" + (countDownBeanNames.size() > 1 ? "s" : "") +
502+
" still running after timeout of " + this.timeout + "ms: " + countDownBeanNames);
503+
}
501504
}
502505
}
503506
catch (InterruptedException ex) {

0 commit comments

Comments
 (0)