Skip to content

Commit a1538a4

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

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
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.
@@ -262,7 +262,9 @@ public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, Strin
262262

263263
public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
264264
Object cacheKey = getCacheKey(bean.getClass(), beanName);
265-
this.earlyProxyReferences.put(cacheKey, Boolean.TRUE);
265+
if (!this.earlyProxyReferences.containsKey(cacheKey)) {
266+
this.earlyProxyReferences.put(cacheKey, Boolean.TRUE);
267+
}
266268
return wrapIfNecessary(bean, beanName, cacheKey);
267269
}
268270

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,9 @@ protected Class<?> getTypeForFactoryBean(String beanName, RootBeanDefinition mbd
13881388
* @param beanName the name of the bean
13891389
*/
13901390
protected void markBeanAsCreated(String beanName) {
1391-
this.alreadyCreated.put(beanName, Boolean.TRUE);
1391+
if (!this.alreadyCreated.containsKey(beanName)) {
1392+
this.alreadyCreated.put(beanName, Boolean.TRUE);
1393+
}
13921394
}
13931395

13941396
/**

0 commit comments

Comments
 (0)