mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Fall back to local synchronization in getObjectFromFactoryBean
Closes gh-35545
This commit is contained in:
+11
-1
@@ -130,7 +130,17 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
|
||||
try {
|
||||
Object object = this.factoryBeanObjectCache.get(beanName);
|
||||
if (object == null) {
|
||||
object = doGetObjectFromFactoryBean(factory, beanName);
|
||||
if (locked) {
|
||||
// The common case: within general singleton lock.
|
||||
object = doGetObjectFromFactoryBean(factory, 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, 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 = this.factoryBeanObjectCache.get(beanName);
|
||||
|
||||
Reference in New Issue
Block a user