Skip to content

Commit

Permalink
AbstractAutoProxyCreator ignores unused early proxy references
Browse files Browse the repository at this point in the history
Closes gh-22370
  • Loading branch information
jhoeller committed Feb 7, 2019
1 parent 8c5cb77 commit af92054
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
Expand Down Expand Up @@ -130,8 +130,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
private final Set<String> targetSourcedBeans =
Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16));

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

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

Expand Down Expand Up @@ -231,9 +230,7 @@ public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, Strin
@Override
public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
Object cacheKey = getCacheKey(bean.getClass(), beanName);
if (!this.earlyProxyReferences.contains(cacheKey)) {
this.earlyProxyReferences.add(cacheKey);
}
this.earlyProxyReferences.put(cacheKey, bean);
return wrapIfNecessary(bean, beanName, cacheKey);
}

Expand Down Expand Up @@ -294,7 +291,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean != null) {
Object cacheKey = getCacheKey(bean.getClass(), beanName);
if (!this.earlyProxyReferences.contains(cacheKey)) {
if (this.earlyProxyReferences.remove(cacheKey) != bean) {
return wrapIfNecessary(bean, beanName, cacheKey);
}
}
Expand Down

0 comments on commit af92054

Please sign in to comment.