Skip to content

Commit 4e731cb

Browse files
committed
Implement StoppableTasklet#stop(StepExecution) in SystemCommandTasklet
1 parent 7eb7782 commit 4e731cb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,21 @@ public void stop() {
275275
stopped = true;
276276
}
277277

278+
/**
279+
* Interrupts the execution of the system command if the given {@link StepExecution}
280+
* matches the current execution context. This method allows for granular control over
281+
* stopping specific step executions, ensuring that only the intended command is halted.
282+
*
283+
* @param stepExecution the current {@link StepExecution} context; the execution is
284+
* interrupted if it matches the ongoing one.
285+
* @since 6.0
286+
* @see StoppableTasklet#stop(StepExecution)
287+
*/
288+
@Override
289+
public void stop(StepExecution stepExecution) {
290+
if (stepExecution.getId().equals(execution.getId())) {
291+
stopped = true;
292+
}
293+
}
294+
278295
}

0 commit comments

Comments
 (0)