Skip to content

Commit af92054

Browse files
committed
AbstractAutoProxyCreator ignores unused early proxy references
Closes gh-22370
1 parent 8c5cb77 commit af92054

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -130,8 +130,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
130130
private final Set<String> targetSourcedBeans =
131131
Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16));
132132

133-
private final Set<Object> earlyProxyReferences =
134-
Collections.newSetFromMap(new ConcurrentHashMap<Object, Boolean>(16));
133+
private final Map<Object, Object> earlyProxyReferences = new ConcurrentHashMap<Object, Object>(16);
135134

136135
private final Map<Object, Class<?>> proxyTypes = new ConcurrentHashMap<Object, Class<?>>(16);
137136

@@ -231,9 +230,7 @@ public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, Strin
231230
@Override
232231
public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
233232
Object cacheKey = getCacheKey(bean.getClass(), beanName);
234-
if (!this.earlyProxyReferences.contains(cacheKey)) {
235-
this.earlyProxyReferences.add(cacheKey);
236-
}
233+
this.earlyProxyReferences.put(cacheKey, bean);
237234
return wrapIfNecessary(bean, beanName, cacheKey);
238235
}
239236

@@ -294,7 +291,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {
294291
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
295292
if (bean != null) {
296293
Object cacheKey = getCacheKey(bean.getClass(), beanName);
297-
if (!this.earlyProxyReferences.contains(cacheKey)) {
294+
if (this.earlyProxyReferences.remove(cacheKey) != bean) {
298295
return wrapIfNecessary(bean, beanName, cacheKey);
299296
}
300297
}

0 commit comments

Comments
 (0)