diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 2d3ef536e81a..979a7d188018 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -1048,7 +1048,7 @@ protected void checkMergedBeanDefinition(RootBeanDefinition mbd, String beanName @Override protected @Nullable Boolean isCurrentThreadAllowedToHoldSingletonLock() { String mainThreadPrefix = this.mainThreadPrefix; - if (this.mainThreadPrefix != null) { + if (mainThreadPrefix != null) { // We only differentiate in the preInstantiateSingletons phase. PreInstantiation preInstantiation = this.preInstantiationThread.get(); @@ -1069,7 +1069,7 @@ protected void checkMergedBeanDefinition(RootBeanDefinition mbd, String beanName } else if (this.strictLocking == null) { // No explicit locking configuration -> infer appropriate locking. - if (mainThreadPrefix != null && !getThreadNamePrefix().equals(mainThreadPrefix)) { + if (!getThreadNamePrefix().equals(mainThreadPrefix)) { // An unmanaged thread (assumed to be application-internal) with lenient locking, // and not part of the same thread pool that provided the main bootstrap thread // (excluding scenarios where we are hit by multiple external bootstrap threads).