Skip to content

Commit ac4103d

Browse files
committed
Further locking optimizations for the retrieval of non-singleton beans
Issue: SPR-12250 (cherry picked from commit 9d83281)
1 parent d23b033 commit ac4103d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -274,7 +274,9 @@ public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, Strin
274274
@Override
275275
public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
276276
Object cacheKey = getCacheKey(bean.getClass(), beanName);
277-
this.earlyProxyReferences.add(cacheKey);
277+
if (!this.earlyProxyReferences.contains(cacheKey)) {
278+
this.earlyProxyReferences.add(cacheKey);
279+
}
278280
return wrapIfNecessary(bean, beanName, cacheKey);
279281
}
280282

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ else if (containsSingleton(beanName)) {
959959

960960
@Override
961961
public boolean isActuallyInCreation(String beanName) {
962-
return isSingletonCurrentlyInCreation(beanName) || isPrototypeCurrentlyInCreation(beanName);
962+
return (isSingletonCurrentlyInCreation(beanName) || isPrototypeCurrentlyInCreation(beanName));
963963
}
964964

965965
/**
@@ -1435,7 +1435,9 @@ protected Class<?> getTypeForFactoryBean(String beanName, RootBeanDefinition mbd
14351435
* @param beanName the name of the bean
14361436
*/
14371437
protected void markBeanAsCreated(String beanName) {
1438-
this.alreadyCreated.add(beanName);
1438+
if (!this.alreadyCreated.contains(beanName)) {
1439+
this.alreadyCreated.add(beanName);
1440+
}
14391441
}
14401442

14411443
/**

0 commit comments

Comments
 (0)