Skip to content

Commit 982ad7d

Browse files
committed
Deprecate JobExecution#stop
Calling jobExecution#stop manually is prone to forgetting to save the job execution in the job repository. The way to request a job execution to stop is by using JobOperator#stop or by using the CommandLineJobRunner with the "-stop" option. Both will correctly set the status to STOPPING and update the job execution in the repository. Resolves #1605
1 parent 7e485a1 commit 982ad7d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2018 the original author or authors.
2+
* Copyright 2006-2020 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.
@@ -254,7 +254,11 @@ public boolean isStopping() {
254254
* Signal the {@link JobExecution} to stop. Iterates through the associated
255255
* {@link StepExecution}s, calling {@link StepExecution#setTerminateOnly()}.
256256
*
257+
* @deprecated Use {@link org.springframework.batch.core.launch.JobOperator#stop(long)}
258+
* or {@link org.springframework.batch.core.launch.support.CommandLineJobRunner}
259+
* with the "-stop" option instead.
257260
*/
261+
@Deprecated
258262
public void stop() {
259263
for (StepExecution stepExecution : stepExecutions) {
260264
stepExecution.setTerminateOnly();

0 commit comments

Comments
 (0)