Cancel without interruption of currently running tasks
Leave potential interruption up to scheduler shutdown.
Closes gh-31019
(cherry picked from commit 6fc5a78252)
This commit is contained in:
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -160,7 +160,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
|||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public ScheduledAnnotationBeanPostProcessor(ScheduledTaskRegistrar registrar) {
|
public ScheduledAnnotationBeanPostProcessor(ScheduledTaskRegistrar registrar) {
|
||||||
Assert.notNull(registrar, "ScheduledTaskRegistrar is required");
|
Assert.notNull(registrar, "ScheduledTaskRegistrar must not be null");
|
||||||
this.registrar = registrar;
|
this.registrar = registrar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,7 +580,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
|||||||
}
|
}
|
||||||
if (tasks != null) {
|
if (tasks != null) {
|
||||||
for (ScheduledTask task : tasks) {
|
for (ScheduledTask task : tasks) {
|
||||||
task.cancel();
|
task.cancel(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -598,7 +598,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
|||||||
Collection<Set<ScheduledTask>> allTasks = this.scheduledTasks.values();
|
Collection<Set<ScheduledTask>> allTasks = this.scheduledTasks.values();
|
||||||
for (Set<ScheduledTask> tasks : allTasks) {
|
for (Set<ScheduledTask> tasks : allTasks) {
|
||||||
for (ScheduledTask task : tasks) {
|
for (ScheduledTask task : tasks) {
|
||||||
task.cancel();
|
task.cancel(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.scheduledTasks.clear();
|
this.scheduledTasks.clear();
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -41,8 +41,8 @@ import org.springframework.util.CollectionUtils;
|
|||||||
* Helper bean for registering tasks with a {@link TaskScheduler}, typically using cron
|
* Helper bean for registering tasks with a {@link TaskScheduler}, typically using cron
|
||||||
* expressions.
|
* expressions.
|
||||||
*
|
*
|
||||||
* <p>As of Spring 3.1, {@code ScheduledTaskRegistrar} has a more prominent user-facing
|
* <p>{@code ScheduledTaskRegistrar} has a more prominent user-facing role when used in
|
||||||
* role when used in conjunction with the {@link
|
* conjunction with the {@link
|
||||||
* org.springframework.scheduling.annotation.EnableAsync @EnableAsync} annotation and its
|
* org.springframework.scheduling.annotation.EnableAsync @EnableAsync} annotation and its
|
||||||
* {@link org.springframework.scheduling.annotation.SchedulingConfigurer
|
* {@link org.springframework.scheduling.annotation.SchedulingConfigurer
|
||||||
* SchedulingConfigurer} callback interface.
|
* SchedulingConfigurer} callback interface.
|
||||||
@@ -552,7 +552,7 @@ public class ScheduledTaskRegistrar implements ScheduledTaskHolder, Initializing
|
|||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
for (ScheduledTask task : this.scheduledTasks) {
|
for (ScheduledTask task : this.scheduledTasks) {
|
||||||
task.cancel();
|
task.cancel(false);
|
||||||
}
|
}
|
||||||
if (this.localExecutor != null) {
|
if (this.localExecutor != null) {
|
||||||
this.localExecutor.shutdownNow();
|
this.localExecutor.shutdownNow();
|
||||||
|
|||||||
Reference in New Issue
Block a user