Skip to content

Commit 0c27510

Browse files
committed
Cancel without interruption of currently running tasks
Leave potential interruption up to scheduler shutdown. Closes gh-31019 (cherry picked from commit 6fc5a78)
1 parent 9931f44 commit 0c27510

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -160,7 +160,7 @@ public ScheduledAnnotationBeanPostProcessor() {
160160
* @since 5.1
161161
*/
162162
public ScheduledAnnotationBeanPostProcessor(ScheduledTaskRegistrar registrar) {
163-
Assert.notNull(registrar, "ScheduledTaskRegistrar is required");
163+
Assert.notNull(registrar, "ScheduledTaskRegistrar must not be null");
164164
this.registrar = registrar;
165165
}
166166

@@ -580,7 +580,7 @@ public void postProcessBeforeDestruction(Object bean, String beanName) {
580580
}
581581
if (tasks != null) {
582582
for (ScheduledTask task : tasks) {
583-
task.cancel();
583+
task.cancel(false);
584584
}
585585
}
586586
}
@@ -598,7 +598,7 @@ public void destroy() {
598598
Collection<Set<ScheduledTask>> allTasks = this.scheduledTasks.values();
599599
for (Set<ScheduledTask> tasks : allTasks) {
600600
for (ScheduledTask task : tasks) {
601-
task.cancel();
601+
task.cancel(false);
602602
}
603603
}
604604
this.scheduledTasks.clear();

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,8 +41,8 @@
4141
* Helper bean for registering tasks with a {@link TaskScheduler}, typically using cron
4242
* expressions.
4343
*
44-
* <p>As of Spring 3.1, {@code ScheduledTaskRegistrar} has a more prominent user-facing
45-
* role when used in conjunction with the {@link
44+
* <p>{@code ScheduledTaskRegistrar} has a more prominent user-facing role when used in
45+
* conjunction with the {@link
4646
* org.springframework.scheduling.annotation.EnableAsync @EnableAsync} annotation and its
4747
* {@link org.springframework.scheduling.annotation.SchedulingConfigurer
4848
* SchedulingConfigurer} callback interface.
@@ -552,7 +552,7 @@ public Set<ScheduledTask> getScheduledTasks() {
552552
@Override
553553
public void destroy() {
554554
for (ScheduledTask task : this.scheduledTasks) {
555-
task.cancel();
555+
task.cancel(false);
556556
}
557557
if (this.localExecutor != null) {
558558
this.localExecutor.shutdownNow();

0 commit comments

Comments
 (0)