Skip to content

Commit

Permalink
Cancel without interruption of currently running tasks
Browse files Browse the repository at this point in the history
Leave potential interruption up to scheduler shutdown.

Closes gh-31019

(cherry picked from commit 6fc5a78)
  • Loading branch information
jhoeller committed Aug 9, 2023
1 parent 9931f44 commit 0c27510
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -160,7 +160,7 @@ public ScheduledAnnotationBeanPostProcessor() {
* @since 5.1
*/
public ScheduledAnnotationBeanPostProcessor(ScheduledTaskRegistrar registrar) {
Assert.notNull(registrar, "ScheduledTaskRegistrar is required");
Assert.notNull(registrar, "ScheduledTaskRegistrar must not be null");
this.registrar = registrar;
}

Expand Down Expand Up @@ -580,7 +580,7 @@ public void postProcessBeforeDestruction(Object bean, String beanName) {
}
if (tasks != null) {
for (ScheduledTask task : tasks) {
task.cancel();
task.cancel(false);
}
}
}
Expand All @@ -598,7 +598,7 @@ public void destroy() {
Collection<Set<ScheduledTask>> allTasks = this.scheduledTasks.values();
for (Set<ScheduledTask> tasks : allTasks) {
for (ScheduledTask task : tasks) {
task.cancel();
task.cancel(false);
}
}
this.scheduledTasks.clear();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,8 +41,8 @@
* Helper bean for registering tasks with a {@link TaskScheduler}, typically using cron
* expressions.
*
* <p>As of Spring 3.1, {@code ScheduledTaskRegistrar} has a more prominent user-facing
* role when used in conjunction with the {@link
* <p>{@code ScheduledTaskRegistrar} has a more prominent user-facing role when used in
* conjunction with the {@link
* org.springframework.scheduling.annotation.EnableAsync @EnableAsync} annotation and its
* {@link org.springframework.scheduling.annotation.SchedulingConfigurer
* SchedulingConfigurer} callback interface.
Expand Down Expand Up @@ -552,7 +552,7 @@ public Set<ScheduledTask> getScheduledTasks() {
@Override
public void destroy() {
for (ScheduledTask task : this.scheduledTasks) {
task.cancel();
task.cancel(false);
}
if (this.localExecutor != null) {
this.localExecutor.shutdownNow();
Expand Down

0 comments on commit 0c27510

Please sign in to comment.