Skip to content

Commit 3b8d878

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

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@
6464
* to the "fixedRate", "fixedDelay", or "cron" expression provided via the annotation.
6565
*
6666
* <p>This post-processor is automatically registered by Spring's
67-
* {@code <task:annotation-driven>} XML element, and also by the @{@link EnableScheduling}
68-
* annotation.
67+
* {@code <task:annotation-driven>} XML element, and also by the
68+
* @{@link EnableScheduling} annotation.
6969
*
70-
* <p>Auto-detects any {@link SchedulingConfigurer} instances in the container,
71-
* allowing for customization of the scheduler to be used or for fine-grained control
72-
* over task registration (e.g. registration of {@link Trigger} tasks.
70+
* <p>Autodetects any {@link SchedulingConfigurer} instances in the container,
71+
* allowing for customization of the scheduler to be used or for fine-grained
72+
* control over task registration (e.g. registration of {@link Trigger} tasks.
7373
* See the @{@link EnableScheduling} javadocs for complete usage details.
7474
*
7575
* @author Mark Fisher
@@ -216,9 +216,9 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {
216216

217217
@Override
218218
public Object postProcessAfterInitialization(final Object bean, String beanName) {
219-
if (!this.nonAnnotatedClasses.contains(bean.getClass())) {
219+
Class<?> targetClass = AopUtils.getTargetClass(bean);
220+
if (!this.nonAnnotatedClasses.contains(targetClass)) {
220221
final Set<Method> annotatedMethods = new LinkedHashSet<Method>(1);
221-
Class<?> targetClass = AopUtils.getTargetClass(bean);
222222
ReflectionUtils.doWithMethods(targetClass, new MethodCallback() {
223223
@Override
224224
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
@@ -230,7 +230,7 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
230230
}
231231
});
232232
if (annotatedMethods.isEmpty()) {
233-
this.nonAnnotatedClasses.add(bean.getClass());
233+
this.nonAnnotatedClasses.add(targetClass);
234234
if (logger.isDebugEnabled()) {
235235
logger.debug("No @Scheduled annotations found on bean class: " + bean.getClass());
236236
}

0 commit comments

Comments
 (0)