Skip to content

Commit

Permalink
Fix dirty flag set to false on same value put
Browse files Browse the repository at this point in the history
  • Loading branch information
GGHDMS committed Oct 27, 2024
1 parent cf44ca8 commit 05e79f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* @author Lucas Ward
* @author Douglas Kaminsky
* @author Mahmoud Ben Hassine
* @author Seokmun Heo
*/
public class ExecutionContext implements Serializable {

Expand Down Expand Up @@ -124,7 +125,11 @@ public void putDouble(String key, double value) {
public void put(String key, @Nullable Object value) {
if (value != null) {
Object result = this.map.put(key, value);
this.dirty = result == null || !result.equals(value);
boolean newDirty = result == null || !result.equals(value);

if (!this.dirty) {
this.dirty = newDirty;
}
}
else {
Object result = this.map.remove(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* @author Lucas Ward
* @author Mahmoud Ben Hassine
*
* @author Seokmun Heo
*/
class ExecutionContextTests {

Expand Down Expand Up @@ -161,6 +161,15 @@ void testCopyConstructorNullInput() {
assertTrue(context.isEmpty());
}

@Test
void testDirtyWithDuplicate() {
ExecutionContext context = new ExecutionContext();
context.put("1", "testString1");
assertTrue(context.isDirty());
context.put("1", "testString1"); // put the same value
assertTrue(context.isDirty());
}

/**
* Value object for testing serialization
*/
Expand Down

0 comments on commit 05e79f3

Please sign in to comment.