Skip to content

Commit 2c98c7d

Browse files
committed
Fix prevent dirty flag from being set to false when pushing null
1 parent b4f4111 commit 2c98c7d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ public void put(String key, @Nullable Object value) {
133133
}
134134
else {
135135
Object result = this.map.remove(key);
136-
this.dirty = result != null;
136+
137+
if (!this.dirty) {
138+
this.dirty = result != null;
139+
}
137140
}
138141
}
139142

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ExecutionContextTests.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ void testNotDirtyWithDuplicate() {
8888
}
8989

9090
@Test
91-
void testNotDirtyWithRemoveMissing() {
91+
void testDirtyWithRemoveMissing() {
9292
context.putString("1", "test");
9393
assertTrue(context.isDirty());
9494
context.putString("1", null); // remove an item that was present
9595
assertTrue(context.isDirty());
96+
97+
context.clearDirtyFlag();
9698
context.putString("1", null); // remove a non-existent item
9799
assertFalse(context.isDirty());
98100
}

0 commit comments

Comments
 (0)