Browse Source

AbstractAutoProxyCreator ignores unused early proxy references

Closes gh-22370
pull/22520/head
Juergen Hoeller 7 years ago
parent
commit
af920544b4
  1. 11
      spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java

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

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -130,8 +130,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
private final Set<String> targetSourcedBeans = private final Set<String> targetSourcedBeans =
Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16)); Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16));
private final Set<Object> earlyProxyReferences = private final Map<Object, Object> earlyProxyReferences = new ConcurrentHashMap<Object, Object>(16);
Collections.newSetFromMap(new ConcurrentHashMap<Object, Boolean>(16));
private final Map<Object, Class<?>> proxyTypes = new ConcurrentHashMap<Object, Class<?>>(16); private final Map<Object, Class<?>> proxyTypes = new ConcurrentHashMap<Object, Class<?>>(16);
@ -231,9 +230,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
@Override @Override
public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException { public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
Object cacheKey = getCacheKey(bean.getClass(), beanName); Object cacheKey = getCacheKey(bean.getClass(), beanName);
if (!this.earlyProxyReferences.contains(cacheKey)) { this.earlyProxyReferences.put(cacheKey, bean);
this.earlyProxyReferences.add(cacheKey);
}
return wrapIfNecessary(bean, beanName, cacheKey); return wrapIfNecessary(bean, beanName, cacheKey);
} }
@ -294,7 +291,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean != null) { if (bean != null) {
Object cacheKey = getCacheKey(bean.getClass(), beanName); Object cacheKey = getCacheKey(bean.getClass(), beanName);
if (!this.earlyProxyReferences.contains(cacheKey)) { if (this.earlyProxyReferences.remove(cacheKey) != bean) {
return wrapIfNecessary(bean, beanName, cacheKey); return wrapIfNecessary(bean, beanName, cacheKey);
} }
} }

Loading…
Cancel
Save