From 2fbdcd42a01e8a85956a41bbfb380208d8a05509 Mon Sep 17 00:00:00 2001 From: Henning Poettker Date: Thu, 30 Nov 2023 10:43:00 +0100 Subject: [PATCH] Check dirty flag of step execution context before update in inner loop --- .../springframework/batch/core/step/tasklet/TaskletStep.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java index b5941c1ec..58a22395c 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java @@ -431,7 +431,9 @@ public class TaskletStep extends AbstractStep { try { // Going to attempt a commit. If it fails this flag will // stay false and we can use that later. - getJobRepository().updateExecutionContext(stepExecution); + if (stepExecution.getExecutionContext().isDirty()) { + getJobRepository().updateExecutionContext(stepExecution); + } stepExecution.incrementCommitCount(); if (logger.isDebugEnabled()) { logger.debug("Saving step execution before commit: " + stepExecution);