Skip to content

Commit aeb77cf

Browse files
committed
Restore correct threadWithLock check without isInfoEnabled()
See gh-23501
1 parent 18dc7d7 commit aeb77cf

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,16 @@ public Object getSingleton(String beanName, ObjectFactory<?> singletonFactory) {
239239
}
240240
else {
241241
Thread threadWithLock = this.singletonCreationThread;
242-
// Another thread is busy in a singleton factory callback, potentially blocked.
243-
// Fallback as of 6.2: process given singleton bean outside of singleton lock.
244-
// Thread-safe exposure is still guaranteed, there is just a risk of collisions
245-
// when triggering creation of other beans as dependencies of the current bean.
246-
if (threadWithLock != null && logger.isInfoEnabled()) {
247-
logger.info("Creating singleton bean '" + beanName + "' in thread \"" +
248-
Thread.currentThread().getName() + "\" while thread \"" + threadWithLock.getName() +
249-
"\" holds singleton lock for other beans " + this.singletonsCurrentlyInCreation);
242+
if (threadWithLock != null) {
243+
// Another thread is busy in a singleton factory callback, potentially blocked.
244+
// Fallback as of 6.2: process given singleton bean outside of singleton lock.
245+
// Thread-safe exposure is still guaranteed, there is just a risk of collisions
246+
// when triggering creation of other beans as dependencies of the current bean.
247+
if (logger.isInfoEnabled()) {
248+
logger.info("Creating singleton bean '" + beanName + "' in thread \"" +
249+
Thread.currentThread().getName() + "\" while thread \"" + threadWithLock.getName() +
250+
"\" holds singleton lock for other beans " + this.singletonsCurrentlyInCreation);
251+
}
250252
}
251253
else {
252254
// Singleton lock currently held by some other registration method -> wait.

0 commit comments

Comments
 (0)