Skip to content

Commit f8a8ecd

Browse files
committed
ScheduledAnnotationBeanPostProcessor uses target class as cache key in case of proxy
Issue: SPR-12709 (cherry picked from commit 1273c90)
1 parent 16df002 commit f8a8ecd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,12 +55,12 @@
5555
* to the "fixedRate", "fixedDelay", or "cron" expression provided via the annotation.
5656
*
5757
* <p>This post-processor is automatically registered by Spring's
58-
* {@code <task:annotation-driven>} XML element, and also by the @{@link EnableScheduling}
59-
* annotation.
58+
* {@code <task:annotation-driven>} XML element, and also by the
59+
* @{@link EnableScheduling} annotation.
6060
*
61-
* <p>Auto-detects any {@link SchedulingConfigurer} instances in the container,
62-
* allowing for customization of the scheduler to be used or for fine-grained control
63-
* over task registration (e.g. registration of {@link Trigger} tasks.
61+
* <p>Autodetects any {@link SchedulingConfigurer} instances in the container,
62+
* allowing for customization of the scheduler to be used or for fine-grained
63+
* control over task registration (e.g. registration of {@link Trigger} tasks.
6464
* See the @{@link EnableScheduling} javadocs for complete usage details.
6565
*
6666
* @author Mark Fisher
@@ -154,9 +154,9 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {
154154
}
155155

156156
public Object postProcessAfterInitialization(final Object bean, String beanName) {
157-
if (!this.nonAnnotatedClasses.containsKey(bean.getClass())) {
157+
Class<?> targetClass = AopUtils.getTargetClass(bean);
158+
if (!this.nonAnnotatedClasses.containsKey(targetClass)) {
158159
final Set<Method> annotatedMethods = new LinkedHashSet<Method>(1);
159-
Class<?> targetClass = AopUtils.getTargetClass(bean);
160160
ReflectionUtils.doWithMethods(targetClass, new MethodCallback() {
161161
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
162162
Scheduled scheduled = AnnotationUtils.getAnnotation(method, Scheduled.class);
@@ -167,7 +167,7 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
167167
}
168168
});
169169
if (annotatedMethods.isEmpty()) {
170-
this.nonAnnotatedClasses.put(bean.getClass(), Boolean.TRUE);
170+
this.nonAnnotatedClasses.put(targetClass, Boolean.TRUE);
171171
}
172172
}
173173
return bean;

0 commit comments

Comments
 (0)