Skip to content

Commit b8e663c

Browse files
committed
AbstractAutoProxyCreator ignores unused early proxy references
Closes gh-22370
1 parent 0f73a69 commit b8e663c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

+4-6
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.
@@ -133,7 +133,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
133133

134134
private final Set<String> targetSourcedBeans = Collections.newSetFromMap(new ConcurrentHashMap<>(16));
135135

136-
private final Set<Object> earlyProxyReferences = Collections.newSetFromMap(new ConcurrentHashMap<>(16));
136+
private final Map<Object, Object> earlyProxyReferences = new ConcurrentHashMap<>(16);
137137

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

@@ -236,9 +236,7 @@ public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, Strin
236236
@Override
237237
public Object getEarlyBeanReference(Object bean, String beanName) {
238238
Object cacheKey = getCacheKey(bean.getClass(), beanName);
239-
if (!this.earlyProxyReferences.contains(cacheKey)) {
240-
this.earlyProxyReferences.add(cacheKey);
241-
}
239+
this.earlyProxyReferences.put(cacheKey, bean);
242240
return wrapIfNecessary(bean, beanName, cacheKey);
243241
}
244242

@@ -297,7 +295,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {
297295
public Object postProcessAfterInitialization(@Nullable Object bean, String beanName) {
298296
if (bean != null) {
299297
Object cacheKey = getCacheKey(bean.getClass(), beanName);
300-
if (!this.earlyProxyReferences.contains(cacheKey)) {
298+
if (this.earlyProxyReferences.remove(cacheKey) != bean) {
301299
return wrapIfNecessary(bean, beanName, cacheKey);
302300
}
303301
}

0 commit comments

Comments
 (0)