Post-processors consistently ignore ScopedObject/AopInfrastructureBean

ScheduledAnnotationBeanPostProcessor also ignores TaskScheduler and ScheduledExecutorService, avoiding unnecessary annotation introspection on framework classes.

Issue: SPR-17166
Issue: SPR-16933
This commit is contained in:
Juergen Hoeller
2018-08-11 22:20:07 +02:00
parent fc16b2d3fb
commit 8bf8092740
5 changed files with 71 additions and 37 deletions

View File

@@ -33,7 +33,9 @@ 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.scope.ScopedObject;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
@@ -331,7 +333,13 @@ public class ScheduledAnnotationBeanPostProcessor
}
@Override
public Object postProcessAfterInitialization(final Object bean, String beanName) {
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) {
return bean;
}
Class<?> targetClass = AopProxyUtils.ultimateTargetClass(bean);
if (!this.nonAnnotatedClasses.contains(targetClass)) {
Map<Method, Set<Scheduled>> annotatedMethods = MethodIntrospector.selectMethods(targetClass,