File tree Expand file tree Collapse file tree 3 files changed +19
-10
lines changed
spring-batch-core/src/main/java/org/springframework/batch/core Expand file tree Collapse file tree 3 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -367,7 +367,9 @@ public boolean stop(JobExecution jobExecution) throws JobExecutionNotRunningExce
367367 }
368368 }
369369 catch (NoSuchJobException e ) {
370- logger .warn ("Cannot find Job object in the job registry. StoppableTasklet#stop(StepExecution stepExecution) will not be called" , e );
370+ logger .warn (
371+ "Cannot find Job object in the job registry. StoppableTasklet#stop(StepExecution stepExecution) will not be called" ,
372+ e );
371373 }
372374
373375 return true ;
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2013 the original author or authors.
2+ * Copyright 2013-present 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.
1515 */
1616package org .springframework .batch .core .step .tasklet ;
1717
18- import org .springframework .batch .core .StepExecution ;
18+ import org .springframework .batch .core .step . StepExecution ;
1919import org .springframework .batch .core .launch .JobOperator ;
2020import org .springframework .batch .core .step .StepContribution ;
2121
@@ -38,17 +38,20 @@ public interface StoppableTasklet extends Tasklet {
3838 /**
3939 * Used to signal that the job this {@link Tasklet} is executing within has been
4040 * requested to stop.
41+ * @deprecated Since 6.0, use {@link #stop(StepExecution)} instead.
4142 */
43+ @ Deprecated (since = "6.0" , forRemoval = true )
4244 void stop ();
4345
4446 /**
4547 * Used to signal that the job should stop, providing access to the current
4648 * {@link StepExecution} context.
47- *
48- * @param stepExecution the current {@link StepExecution} context in which the job
49- * is being executed
49+ * @param stepExecution the current {@link StepExecution} context in which the job is
50+ * being executed
51+ * @since 6.0
5052 */
5153 default void stop (StepExecution stepExecution ) {
5254 stop ();
5355 }
56+
5457}
Original file line number Diff line number Diff line change @@ -279,17 +279,21 @@ public void stop() {
279279 /**
280280 * Interrupts the execution of the system command if the given {@link StepExecution}
281281 * matches the current execution context. This method allows for granular control over
282- * stopping specific step executions, ensuring that only the intended command is halted.
283- *
282+ * stopping specific step executions, ensuring that only the intended command is
283+ * halted.
284+ * <p>
285+ * This method will interrupt the thread executing the system command only if
286+ * {@link #setInterruptOnCancel(boolean)} has been set to true. Otherwise, the
287+ * underlying command will be allowed to finish before the tasklet ends.
284288 * @param stepExecution the current {@link StepExecution} context; the execution is
285289 * interrupted if it matches the ongoing one.
286290 * @since 6.0
287291 * @see StoppableTasklet#stop(StepExecution)
288292 */
289293 @ Override
290294 public void stop (StepExecution stepExecution ) {
291- if (stepExecution .equals (execution )) {
292- stopped = true ;
295+ if (stepExecution .equals (this . execution )) {
296+ this . stopped = true ;
293297 }
294298 }
295299
You can’t perform that action at this time.
0 commit comments