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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user