From 3576ff051cf13ccc97d8b0fea8d961d204c15f0d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 30 May 2016 22:47:31 +0200 Subject: [PATCH] ScheduledAnnotationBeanPostProcessor properly registers multiple tasks per bean Issue: SPR-14286 --- .../annotation/ScheduledAnnotationBeanPostProcessor.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 f37530ac1a..87431b95a7 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 @@ -302,8 +302,11 @@ public class ScheduledAnnotationBeanPostProcessor implements DestructionAwareBea String errorMessage = "Exactly one of the 'cron', 'fixedDelay(String)', or 'fixedRate(String)' attributes is required"; - Set tasks = - new LinkedHashSet(4); + Set tasks = this.scheduledTasks.get(bean); + if (tasks == null) { + tasks = new LinkedHashSet(4); + this.scheduledTasks.put(bean, tasks); + } // Determine initial delay long initialDelay = scheduled.initialDelay(); @@ -397,7 +400,6 @@ public class ScheduledAnnotationBeanPostProcessor implements DestructionAwareBea // Check whether we had any attribute set Assert.isTrue(processedSchedule, errorMessage); - this.scheduledTasks.put(bean, tasks); } catch (IllegalArgumentException ex) { throw new IllegalStateException(