From 874b92d4b2628fc58c6dedb60beaf429bcd198fb Mon Sep 17 00:00:00 2001 From: Michael Minella Date: Fri, 27 Dec 2013 11:46:39 -0600 Subject: [PATCH] BATCH-2151: Clean up ChunkMonitor offset on chunk boundries --- .../springframework/batch/core/step/item/ChunkMonitor.java | 1 + .../batch/core/step/item/ChunkMonitorTests.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java index d13dff26c..3968c4009 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java @@ -140,6 +140,7 @@ public class ChunkMonitor extends ItemStreamSupport { // Only call the underlying update method if we are on a chunk // boundary stream.update(executionContext); + executionContext.remove(getExecutionContextKey(OFFSET)); } else { executionContext.putInt(getExecutionContextKey(OFFSET), data.offset); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java index 3d8c6be30..137ed0cfb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java @@ -128,6 +128,10 @@ public class ChunkMonitorTests { ExecutionContext executionContext = new ExecutionContext(); monitor.update(executionContext); assertEquals(0, executionContext.size()); + + executionContext.put(ChunkMonitor.class.getName() + ".OFFSET", 3); + monitor.update(executionContext); + assertEquals(0, executionContext.size()); } @Test