Browse Source

Further locking optimizations for the retrieval of non-singleton beans

Issue: SPR-12250
pull/656/head
Juergen Hoeller 11 years ago
parent
commit
9d832816a8
  1. 2
      spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java
  2. 4
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

2
spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java

@ -226,7 +226,9 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
@Override @Override
public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException { public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
Object cacheKey = getCacheKey(bean.getClass(), beanName); Object cacheKey = getCacheKey(bean.getClass(), beanName);
if (!this.earlyProxyReferences.contains(cacheKey)) {
this.earlyProxyReferences.add(cacheKey); this.earlyProxyReferences.add(cacheKey);
}
return wrapIfNecessary(bean, beanName, cacheKey); return wrapIfNecessary(bean, beanName, cacheKey);
} }

4
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

@ -959,7 +959,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@Override @Override
public boolean isActuallyInCreation(String beanName) { public boolean isActuallyInCreation(String beanName) {
return isSingletonCurrentlyInCreation(beanName) || isPrototypeCurrentlyInCreation(beanName); return (isSingletonCurrentlyInCreation(beanName) || isPrototypeCurrentlyInCreation(beanName));
} }
/** /**
@ -1435,8 +1435,10 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
* @param beanName the name of the bean * @param beanName the name of the bean
*/ */
protected void markBeanAsCreated(String beanName) { protected void markBeanAsCreated(String beanName) {
if (!this.alreadyCreated.contains(beanName)) {
this.alreadyCreated.add(beanName); this.alreadyCreated.add(beanName);
} }
}
/** /**
* Perform appropriate cleanup of cached metadata after bean creation failed. * Perform appropriate cleanup of cached metadata after bean creation failed.

Loading…
Cancel
Save