Browse Source

Cancel without interruption of currently running tasks

Leave potential interruption up to scheduler shutdown.

Closes gh-31019
pull/31496/head
Juergen Hoeller 2 years ago
parent
commit
6fc5a78252
  1. 4
      spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java
  2. 2
      spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java

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

@ -577,7 +577,7 @@ public class ScheduledAnnotationBeanPostProcessor @@ -577,7 +577,7 @@ public class ScheduledAnnotationBeanPostProcessor
}
if (tasks != null) {
for (ScheduledTask task : tasks) {
task.cancel();
task.cancel(false);
}
}
}
@ -595,7 +595,7 @@ public class ScheduledAnnotationBeanPostProcessor @@ -595,7 +595,7 @@ public class ScheduledAnnotationBeanPostProcessor
Collection<Set<ScheduledTask>> allTasks = this.scheduledTasks.values();
for (Set<ScheduledTask> tasks : allTasks) {
for (ScheduledTask task : tasks) {
task.cancel();
task.cancel(false);
}
}
this.scheduledTasks.clear();

2
spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java

@ -553,7 +553,7 @@ public class ScheduledTaskRegistrar implements ScheduledTaskHolder, Initializing @@ -553,7 +553,7 @@ public class ScheduledTaskRegistrar implements ScheduledTaskHolder, Initializing
@Override
public void destroy() {
for (ScheduledTask task : this.scheduledTasks) {
task.cancel();
task.cancel(false);
}
if (this.localExecutor != null) {
this.localExecutor.shutdownNow();

Loading…
Cancel
Save