DefaultSingletonBeanRegistry avoids singletonObjects lock wherever possible for non-singleton factory performance
Issue: SPR-9819
This commit is contained in:
parent
e1d11ec99d
commit
c24825ca19
|
|
@ -166,7 +166,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getSingleton(String beanName) {
|
public Object getSingleton(String beanName) {
|
||||||
return getSingleton(beanName, true);
|
return getSingleton(beanName, isSingletonCurrentlyInCreation(beanName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -179,10 +179,10 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
||||||
*/
|
*/
|
||||||
protected Object getSingleton(String beanName, boolean allowEarlyReference) {
|
protected Object getSingleton(String beanName, boolean allowEarlyReference) {
|
||||||
Object singletonObject = this.singletonObjects.get(beanName);
|
Object singletonObject = this.singletonObjects.get(beanName);
|
||||||
if (singletonObject == null) {
|
if (singletonObject == null && allowEarlyReference) {
|
||||||
synchronized (this.singletonObjects) {
|
synchronized (this.singletonObjects) {
|
||||||
singletonObject = this.earlySingletonObjects.get(beanName);
|
singletonObject = this.earlySingletonObjects.get(beanName);
|
||||||
if (singletonObject == null && allowEarlyReference) {
|
if (singletonObject == null) {
|
||||||
ObjectFactory singletonFactory = this.singletonFactories.get(beanName);
|
ObjectFactory singletonFactory = this.singletonFactories.get(beanName);
|
||||||
if (singletonFactory != null) {
|
if (singletonFactory != null) {
|
||||||
singletonObject = singletonFactory.getObject();
|
singletonObject = singletonFactory.getObject();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue