From 71d4dbea13a993d8801ea814c49bcf562b918c0a Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sat, 11 Aug 2018 23:10:57 +0200 Subject: [PATCH] Post-processors ignore AopInfrastructureBean (includes ScopedObject) Issue: SPR-17166 --- .../aop/framework/AbstractAdvisingBeanPostProcessor.java | 5 ++--- .../annotation/ScheduledAnnotationBeanPostProcessor.java | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java b/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java index 50bdb3a75c..b08de06d5c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java @@ -20,7 +20,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.springframework.aop.Advisor; -import org.springframework.aop.scope.ScopedObject; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.lang.Nullable; @@ -64,7 +63,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu @Override public Object postProcessAfterInitialization(Object bean, String beanName) { - if (this.advisor == null || bean instanceof ScopedObject || bean instanceof AopInfrastructureBean) { + if (this.advisor == null || bean instanceof AopInfrastructureBean) { // Ignore AOP infrastructure such as scoped proxies. return bean; } @@ -93,7 +92,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu return proxyFactory.getProxy(getProxyClassLoader()); } - // No async proxy needed. + // No proxy needed. return bean; } diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java index 6496ddcf6f..b4789513d9 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java @@ -35,7 +35,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.aop.framework.AopInfrastructureBean; import org.springframework.aop.framework.AopProxyUtils; -import org.springframework.aop.scope.ScopedObject; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; @@ -334,9 +333,9 @@ public class ScheduledAnnotationBeanPostProcessor @Override public Object postProcessAfterInitialization(Object bean, String beanName) { - // Only process scoped target instances, not scoped proxies... - if (bean instanceof ScopedObject || bean instanceof AopInfrastructureBean || - bean instanceof TaskScheduler || bean instanceof ScheduledExecutorService) { + if (bean instanceof AopInfrastructureBean || bean instanceof TaskScheduler || + bean instanceof ScheduledExecutorService) { + // Ignore AOP infrastructure such as scoped proxies. return bean; }