From ac4103d1b9876067f6eb2a57654de8f9155da639 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 6 Oct 2014 17:42:51 +0200 Subject: [PATCH] Further locking optimizations for the retrieval of non-singleton beans Issue: SPR-12250 (cherry picked from commit 9d83281) --- .../aop/framework/autoproxy/AbstractAutoProxyCreator.java | 6 ++++-- .../beans/factory/support/AbstractBeanFactory.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java index 628cff540d5..a8b47d32e21 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -274,7 +274,9 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig @Override public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException { Object cacheKey = getCacheKey(bean.getClass(), beanName); - this.earlyProxyReferences.add(cacheKey); + if (!this.earlyProxyReferences.contains(cacheKey)) { + this.earlyProxyReferences.add(cacheKey); + } return wrapIfNecessary(bean, beanName, cacheKey); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index 526ebd73c55..d0a8f18ac8b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -959,7 +959,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @Override public boolean isActuallyInCreation(String beanName) { - return isSingletonCurrentlyInCreation(beanName) || isPrototypeCurrentlyInCreation(beanName); + return (isSingletonCurrentlyInCreation(beanName) || isPrototypeCurrentlyInCreation(beanName)); } /** @@ -1435,7 +1435,9 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp * @param beanName the name of the bean */ protected void markBeanAsCreated(String beanName) { - this.alreadyCreated.add(beanName); + if (!this.alreadyCreated.contains(beanName)) { + this.alreadyCreated.add(beanName); + } } /**