Skip to content

Commit

Permalink
Post-processors ignore AopInfrastructureBean (includes ScopedObject)
Browse files Browse the repository at this point in the history
Issue: SPR-17166
  • Loading branch information
jhoeller committed Aug 11, 2018
1 parent 8bf8092 commit 71d4dbe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
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;
Expand Down Expand Up @@ -64,7 +63,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {

@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;
}
Expand Down Expand Up @@ -93,7 +92,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) {
return proxyFactory.getProxy(getProxyClassLoader());
}

// No async proxy needed.
// No proxy needed.
return bean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

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;
Expand Down Expand Up @@ -334,9 +333,9 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {

@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;
}

Expand Down

0 comments on commit 71d4dbe

Please sign in to comment.