Leniently accept same singleton instance if implicitly appeared
Closes gh-34427
This commit is contained in:
@@ -368,8 +368,18 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
||||
}
|
||||
afterSingletonCreation(beanName);
|
||||
}
|
||||
|
||||
if (newSingleton) {
|
||||
addSingleton(beanName, singletonObject);
|
||||
try {
|
||||
addSingleton(beanName, singletonObject);
|
||||
}
|
||||
catch (IllegalStateException ex) {
|
||||
// Leniently accept same instance if implicitly appeared.
|
||||
Object object = this.singletonObjects.get(beanName);
|
||||
if (singletonObject != object) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return singletonObject;
|
||||
|
||||
Reference in New Issue
Block a user