Evaluate lenientLockingAllowed flag per DefaultListableBeanFactory instance

See gh-34303
This commit is contained in:
Juergen Hoeller 2025-03-28 20:45:06 +01:00
parent 8d2166139f
commit 9bf01df230
1 changed files with 4 additions and 3 deletions

View File

@ -138,8 +138,6 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
*/
public static final String STRICT_LOCKING_PROPERTY_NAME = "spring.locking.strict";
private static final boolean lenientLockingAllowed = !SpringProperties.getFlag(STRICT_LOCKING_PROPERTY_NAME);
@Nullable
private static Class<?> jakartaInjectProviderClass;
@ -159,6 +157,9 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
private static final Map<String, Reference<DefaultListableBeanFactory>> serializableFactories =
new ConcurrentHashMap<>(8);
/** Whether lenient locking is allowed in this factory. */
private final boolean lenientLockingAllowed = !SpringProperties.getFlag(STRICT_LOCKING_PROPERTY_NAME);
/** Optional id for this factory, for serialization purposes. */
@Nullable
private String serializationId;
@ -1051,7 +1052,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
@Override
@Nullable
protected Boolean isCurrentThreadAllowedToHoldSingletonLock() {
return (lenientLockingAllowed && this.preInstantiationPhase ?
return (this.lenientLockingAllowed && this.preInstantiationPhase ?
this.preInstantiationThread.get() != PreInstantiation.BACKGROUND : null);
}