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
This commit is contained in:
Mahmoud Ben Hassine
2020-09-15 13:54:23 +02:00
parent 7e485a1b2b
commit 982ad7d5e9

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2018 the original author or authors.
* Copyright 2006-2020 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.
@@ -254,7 +254,11 @@ public class JobExecution extends Entity {
* Signal the {@link JobExecution} to stop. Iterates through the associated
* {@link StepExecution}s, calling {@link StepExecution#setTerminateOnly()}.
*
* @deprecated Use {@link org.springframework.batch.core.launch.JobOperator#stop(long)}
* or {@link org.springframework.batch.core.launch.support.CommandLineJobRunner}
* with the "-stop" option instead.
*/
@Deprecated
public void stop() {
for (StepExecution stepExecution : stepExecutions) {
stepExecution.setTerminateOnly();