From 6fc5a782524881d27c0c2f35b425fdecf61f463f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 9 Aug 2023 23:53:35 +0200 Subject: [PATCH] Cancel without interruption of currently running tasks Leave potential interruption up to scheduler shutdown. Closes gh-31019 --- .../annotation/ScheduledAnnotationBeanPostProcessor.java | 4 ++-- .../scheduling/config/ScheduledTaskRegistrar.java | 2 +- 2 files changed, 3 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 14272d35e776..1d6f002d09a1 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 @@ -577,7 +577,7 @@ public void postProcessBeforeDestruction(Object bean, String beanName) { } if (tasks != null) { for (ScheduledTask task : tasks) { - task.cancel(); + task.cancel(false); } } } @@ -595,7 +595,7 @@ public void destroy() { Collection> allTasks = this.scheduledTasks.values(); for (Set tasks : allTasks) { for (ScheduledTask task : tasks) { - task.cancel(); + task.cancel(false); } } this.scheduledTasks.clear(); diff --git a/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java b/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java index 5ded56096136..657c7535f5d3 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java +++ b/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java @@ -553,7 +553,7 @@ public Set getScheduledTasks() { @Override public void destroy() { for (ScheduledTask task : this.scheduledTasks) { - task.cancel(); + task.cancel(false); } if (this.localExecutor != null) { this.localExecutor.shutdownNow();