Merge branch '6.2.x'
# Conflicts: # spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java
This commit is contained in:
commit
2170b40213
|
@ -132,19 +132,13 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
|
|||
try {
|
||||
// A SmartFactoryBean may return multiple object types -> do not cache.
|
||||
boolean smart = (factory instanceof SmartFactoryBean<?>);
|
||||
// Defensively synchronize against non-thread-safe FactoryBean.getObject() implementations,
|
||||
// potentially to be called from a background thread while the main thread currently calls
|
||||
// the same getObject() method within the singleton lock.
|
||||
synchronized (factory) {
|
||||
Object object = (!smart ? this.factoryBeanObjectCache.get(beanName) : null);
|
||||
if (object == null) {
|
||||
if (locked) {
|
||||
// The common case: within general singleton lock.
|
||||
object = doGetObjectFromFactoryBean(factory, requiredType, beanName);
|
||||
}
|
||||
else {
|
||||
// Fall back to local synchronization on the given FactoryBean instance,
|
||||
// as a defensive measure for non-thread-safe FactoryBean implementations.
|
||||
synchronized (factory) {
|
||||
object = doGetObjectFromFactoryBean(factory, requiredType, beanName);
|
||||
}
|
||||
}
|
||||
// Only post-process and store if not put there already during getObject() call above
|
||||
// (for example, because of circular reference processing triggered by custom getBean calls)
|
||||
Object alreadyThere = (!smart ? this.factoryBeanObjectCache.get(beanName) : null);
|
||||
|
@ -180,6 +174,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
|
|||
}
|
||||
return object;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (locked) {
|
||||
this.singletonLock.unlock();
|
||||
|
|
Loading…
Reference in New Issue