Skip to content

Commit 30ba4e3

Browse files
committed
Implement StoppableTasklet#stop(StepExecution) in SystemCommandTasklet
1 parent 0000909 commit 30ba4e3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java

+18
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
* @author Will Schipp
6262
* @author Mahmoud Ben Hassine
6363
* @author Injae Kim
64+
* @author Hyunsang Han
6465
*/
6566
public class SystemCommandTasklet implements StepExecutionListener, StoppableTasklet, InitializingBean {
6667

@@ -275,4 +276,21 @@ public void stop() {
275276
stopped = true;
276277
}
277278

279+
/**
280+
* Interrupts the execution of the system command if the given {@link StepExecution}
281+
* 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+
*
284+
* @param stepExecution the current {@link StepExecution} context; the execution is
285+
* interrupted if it matches the ongoing one.
286+
* @since 6.0
287+
* @see StoppableTasklet#stop(StepExecution)
288+
*/
289+
@Override
290+
public void stop(StepExecution stepExecution) {
291+
if (stepExecution.equals(execution)) {
292+
stopped = true;
293+
}
294+
}
295+
278296
}

0 commit comments

Comments
 (0)