From 1273c90a645a4fcc79719f14b4dc500106dfac2b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 18 Feb 2015 16:16:05 +0100 Subject: [PATCH] ScheduledAnnotationBeanPostProcessor uses target class as cache key in case of proxy Issue: SPR-12709 --- .../ScheduledAnnotationBeanPostProcessor.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 8f6a2a82f96..608e4c964fb 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 @@ -64,12 +64,12 @@ import org.springframework.util.StringValueResolver; * to the "fixedRate", "fixedDelay", or "cron" expression provided via the annotation. * *

This post-processor is automatically registered by Spring's - * {@code } XML element, and also by the @{@link EnableScheduling} - * annotation. + * {@code } XML element, and also by the + * @{@link EnableScheduling} annotation. * - *

Auto-detects any {@link SchedulingConfigurer} instances in the container, - * allowing for customization of the scheduler to be used or for fine-grained control - * over task registration (e.g. registration of {@link Trigger} tasks. + *

Autodetects any {@link SchedulingConfigurer} instances in the container, + * allowing for customization of the scheduler to be used or for fine-grained + * control over task registration (e.g. registration of {@link Trigger} tasks. * See the @{@link EnableScheduling} javadocs for complete usage details. * * @author Mark Fisher @@ -216,9 +216,9 @@ public class ScheduledAnnotationBeanPostProcessor implements BeanPostProcessor, @Override public Object postProcessAfterInitialization(final Object bean, String beanName) { - if (!this.nonAnnotatedClasses.contains(bean.getClass())) { + Class targetClass = AopUtils.getTargetClass(bean); + if (!this.nonAnnotatedClasses.contains(targetClass)) { final Set annotatedMethods = new LinkedHashSet(1); - Class targetClass = AopUtils.getTargetClass(bean); ReflectionUtils.doWithMethods(targetClass, new MethodCallback() { @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { @@ -230,7 +230,7 @@ public class ScheduledAnnotationBeanPostProcessor implements BeanPostProcessor, } }); if (annotatedMethods.isEmpty()) { - this.nonAnnotatedClasses.add(bean.getClass()); + this.nonAnnotatedClasses.add(targetClass); if (logger.isDebugEnabled()) { logger.debug("No @Scheduled annotations found on bean class: " + bean.getClass()); }