Skip to content

Commit 7401f7e

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

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,13 +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());
9696
context.putString("1", null); // remove a non-existent item
97-
assertFalse(context.isDirty());
97+
assertTrue(context.isDirty());
9898
}
9999

100100
@Test

0 commit comments

Comments
 (0)