Skip to content

Commit 89661ae

Browse files
committed
Check if job is stopping before checking interrupt
1 parent 425134c commit 89661ae

File tree

1 file changed

+7
-0
lines changed
  • spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.commons.logging.LogFactory;
2020
import org.springframework.batch.core.BatchStatus;
2121
import org.springframework.batch.core.ChunkListener;
22+
import org.springframework.batch.core.JobExecution;
2223
import org.springframework.batch.core.JobInterruptedException;
2324
import org.springframework.batch.core.StepContribution;
2425
import org.springframework.batch.core.StepExecution;
@@ -256,6 +257,12 @@ public RepeatStatus doInChunkContext(RepeatContext repeatContext, ChunkContext c
256257

257258
chunkListener.afterChunk(chunkContext);
258259

260+
final JobExecution jobExecution = stepExecution.getJobExecution();
261+
if (jobExecution.isStopping()) {
262+
logger.info("Parent JobExecution is stopped, so passing message on to StepExecution");
263+
stepExecution.setTerminateOnly();
264+
}
265+
259266
// Check for interruption after transaction as well, so that
260267
// the interrupted exception is correctly propagated up to
261268
// caller

0 commit comments

Comments
 (0)