Browse Source

Evaluate lenientLockingAllowed flag per DefaultListableBeanFactory instance

See gh-34303
pull/34732/head
Juergen Hoeller 1 year ago
parent
commit
9bf01df230
  1. 7
      spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

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

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

Loading…
Cancel
Save