Skip to content

Commit 9bf01df

Browse files
committed
Evaluate lenientLockingAllowed flag per DefaultListableBeanFactory instance
See gh-34303
1 parent 8d21661 commit 9bf01df

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
138138
*/
139139
public static final String STRICT_LOCKING_PROPERTY_NAME = "spring.locking.strict";
140140

141-
private static final boolean lenientLockingAllowed = !SpringProperties.getFlag(STRICT_LOCKING_PROPERTY_NAME);
142-
143141
@Nullable
144142
private static Class<?> jakartaInjectProviderClass;
145143

@@ -159,6 +157,9 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
159157
private static final Map<String, Reference<DefaultListableBeanFactory>> serializableFactories =
160158
new ConcurrentHashMap<>(8);
161159

160+
/** Whether lenient locking is allowed in this factory. */
161+
private final boolean lenientLockingAllowed = !SpringProperties.getFlag(STRICT_LOCKING_PROPERTY_NAME);
162+
162163
/** Optional id for this factory, for serialization purposes. */
163164
@Nullable
164165
private String serializationId;
@@ -1051,7 +1052,7 @@ protected void checkMergedBeanDefinition(RootBeanDefinition mbd, String beanName
10511052
@Override
10521053
@Nullable
10531054
protected Boolean isCurrentThreadAllowedToHoldSingletonLock() {
1054-
return (lenientLockingAllowed && this.preInstantiationPhase ?
1055+
return (this.lenientLockingAllowed && this.preInstantiationPhase ?
10551056
this.preInstantiationThread.get() != PreInstantiation.BACKGROUND : null);
10561057
}
10571058

0 commit comments

Comments
 (0)