From 4e731cbec2a32e06566c5df48d7e2c60f3f1d999 Mon Sep 17 00:00:00 2001 From: Travis Date: Sun, 24 Nov 2024 13:18:49 +0900 Subject: [PATCH] Implement StoppableTasklet#stop(StepExecution) in SystemCommandTasklet --- .../core/step/tasklet/SystemCommandTasklet.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java index 4499279e8e..0bf74fe306 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java @@ -275,4 +275,21 @@ public void stop() { stopped = true; } + /** + * Interrupts the execution of the system command if the given {@link StepExecution} + * matches the current execution context. This method allows for granular control over + * stopping specific step executions, ensuring that only the intended command is halted. + * + * @param stepExecution the current {@link StepExecution} context; the execution is + * interrupted if it matches the ongoing one. + * @since 6.0 + * @see StoppableTasklet#stop(StepExecution) + */ + @Override + public void stop(StepExecution stepExecution) { + if (stepExecution.getId().equals(execution.getId())) { + stopped = true; + } + } + }