Skip to content

Commit d3a5aef

Browse files
authored
Improve handling of mainThreadPrefix and remove redundant null check (#34746)
1 parent fc516cb commit d3a5aef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ protected void checkMergedBeanDefinition(RootBeanDefinition mbd, String beanName
10481048
@Override
10491049
protected @Nullable Boolean isCurrentThreadAllowedToHoldSingletonLock() {
10501050
String mainThreadPrefix = this.mainThreadPrefix;
1051-
if (this.mainThreadPrefix != null) {
1051+
if (mainThreadPrefix != null) {
10521052
// We only differentiate in the preInstantiateSingletons phase.
10531053

10541054
PreInstantiation preInstantiation = this.preInstantiationThread.get();
@@ -1069,7 +1069,7 @@ protected void checkMergedBeanDefinition(RootBeanDefinition mbd, String beanName
10691069
}
10701070
else if (this.strictLocking == null) {
10711071
// No explicit locking configuration -> infer appropriate locking.
1072-
if (mainThreadPrefix != null && !getThreadNamePrefix().equals(mainThreadPrefix)) {
1072+
if (!getThreadNamePrefix().equals(mainThreadPrefix)) {
10731073
// An unmanaged thread (assumed to be application-internal) with lenient locking,
10741074
// and not part of the same thread pool that provided the main bootstrap thread
10751075
// (excluding scenarios where we are hit by multiple external bootstrap threads).

0 commit comments

Comments
 (0)