Skip to content

Commit

Permalink
Fix prevent dirty flag from being set to false when pushing null
Browse files Browse the repository at this point in the history
  • Loading branch information
GGHDMS committed Oct 28, 2024
1 parent b4f4111 commit 2c98c7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ public void put(String key, @Nullable Object value) {
}
else {
Object result = this.map.remove(key);
this.dirty = result != null;

if (!this.dirty) {
this.dirty = result != null;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ void testNotDirtyWithDuplicate() {
}

@Test
void testNotDirtyWithRemoveMissing() {
void testDirtyWithRemoveMissing() {
context.putString("1", "test");
assertTrue(context.isDirty());
context.putString("1", null); // remove an item that was present
assertTrue(context.isDirty());

context.clearDirtyFlag();
context.putString("1", null); // remove a non-existent item
assertFalse(context.isDirty());
}
Expand Down

0 comments on commit 2c98c7d

Please sign in to comment.