From 982ad7d5e9455188b9d152de607268bc45403049 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Tue, 15 Sep 2020 13:54:23 +0200 Subject: [PATCH] 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 --- .../java/org/springframework/batch/core/JobExecution.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java index 0618edef0..742d076f5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java @@ -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();