Post-processors consistently ignore ScopedObject/AopInfrastructureBean

Issue: SPR-17166
This commit is contained in:
Juergen Hoeller
2018-08-11 22:46:17 +02:00
parent 687d350b57
commit b51685bf00
5 changed files with 82 additions and 47 deletions

View File

@@ -32,6 +32,7 @@ import java.util.concurrent.ScheduledExecutorService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.framework.AopInfrastructureBean;
import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanFactory;
@@ -306,7 +307,12 @@ public class ScheduledAnnotationBeanPostProcessor
}
@Override
public Object postProcessAfterInitialization(final Object bean, String beanName) {
public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof AopInfrastructureBean) {
// Ignore AOP infrastructure such as scoped proxies.
return bean;
}
Class<?> targetClass = AopProxyUtils.ultimateTargetClass(bean);
if (!this.nonAnnotatedClasses.contains(targetClass)) {
Map<Method, Set<Scheduled>> annotatedMethods = MethodIntrospector.selectMethods(targetClass,
@@ -341,6 +347,12 @@ public class ScheduledAnnotationBeanPostProcessor
return bean;
}
/**
* Process the given {@code @Scheduled} method declaration on the given bean.
* @param scheduled the @Scheduled annotation
* @param method the method that the annotation has been declared on
* @param bean the target bean instance
*/
protected void processScheduled(Scheduled scheduled, Method method, Object bean) {
try {
Assert.isTrue(method.getParameterTypes().length == 0,