From 67e3b1b5310b9ecc4cbcab6dab1262d5369bbde8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=85=B6=E8=8B=97?= Date: Mon, 4 Nov 2019 00:03:42 +0800 Subject: [PATCH 1/2] Rename earlyProxyReferences in AbstractAutoProxyCreator See gh-23914 --- .../aop/framework/autoproxy/AbstractAutoProxyCreator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 502fd9e292..05a7296625 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 @@ -138,7 +138,8 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport private final Set targetSourcedBeans = Collections.newSetFromMap(new ConcurrentHashMap<>(16)); - private final Map earlyProxyReferences = new ConcurrentHashMap<>(16); + /** Cache of early target objects: cacheKey to bean instance. */ + private final Map earlyTargetReferences = new ConcurrentHashMap<>(16); private final Map> proxyTypes = new ConcurrentHashMap<>(16); @@ -265,7 +266,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport @Override public Object getEarlyBeanReference(Object bean, String beanName) { Object cacheKey = getCacheKey(bean.getClass(), beanName); - this.earlyProxyReferences.put(cacheKey, bean); + this.earlyTargetReferences.put(cacheKey, bean); return wrapIfNecessary(bean, beanName, cacheKey); } @@ -314,7 +315,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport public Object postProcessAfterInitialization(@Nullable Object bean, String beanName) { if (bean != null) { Object cacheKey = getCacheKey(bean.getClass(), beanName); - if (this.earlyProxyReferences.remove(cacheKey) != bean) { + if (this.earlyTargetReferences.remove(cacheKey) != bean) { return wrapIfNecessary(bean, beanName, cacheKey); } } From 5d5cd17d33c59f105f992373d6e0aa013c7a02d3 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 23 Aug 2023 15:34:22 +0200 Subject: [PATCH 2/2] Polish "Rename earlyProxyReferences in AbstractAutoProxyCreator" See gh-23914 --- .../framework/autoproxy/AbstractAutoProxyCreator.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 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 05a7296625..611a1bac8b 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-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -138,8 +138,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport private final Set targetSourcedBeans = Collections.newSetFromMap(new ConcurrentHashMap<>(16)); - /** Cache of early target objects: cacheKey to bean instance. */ - private final Map earlyTargetReferences = new ConcurrentHashMap<>(16); + private final Map earlyBeanReferences = new ConcurrentHashMap<>(16); private final Map> proxyTypes = new ConcurrentHashMap<>(16); @@ -266,7 +265,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport @Override public Object getEarlyBeanReference(Object bean, String beanName) { Object cacheKey = getCacheKey(bean.getClass(), beanName); - this.earlyTargetReferences.put(cacheKey, bean); + this.earlyBeanReferences.put(cacheKey, bean); return wrapIfNecessary(bean, beanName, cacheKey); } @@ -315,7 +314,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport public Object postProcessAfterInitialization(@Nullable Object bean, String beanName) { if (bean != null) { Object cacheKey = getCacheKey(bean.getClass(), beanName); - if (this.earlyTargetReferences.remove(cacheKey) != bean) { + if (this.earlyBeanReferences.remove(cacheKey) != bean) { return wrapIfNecessary(bean, beanName, cacheKey); } }