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 f37530ac1ab..87431b95a74 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(