diff --git a/core/src/main/java/org/dcsa/conformance/core/state/MemorySortedPartitionsNonLockingMap.java b/core/src/main/java/org/dcsa/conformance/core/state/MemorySortedPartitionsNonLockingMap.java index d1ff3e3f..e3c2a854 100644 --- a/core/src/main/java/org/dcsa/conformance/core/state/MemorySortedPartitionsNonLockingMap.java +++ b/core/src/main/java/org/dcsa/conformance/core/state/MemorySortedPartitionsNonLockingMap.java @@ -2,6 +2,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.SneakyThrows; + import java.util.HashMap; import java.util.List; import java.util.TreeMap; @@ -9,11 +11,13 @@ public class MemorySortedPartitionsNonLockingMap implements SortedPartitionsNonLockingMap { private final HashMap> memoryMap = new HashMap<>(); + @SneakyThrows @Override public synchronized void setItemValue(String partitionKey, String sortKey, JsonNode value) { + JsonNode valueCopy = new ObjectMapper().readTree(value.toString()); memoryMap .computeIfAbsent(partitionKey, (ignoredKey) -> new TreeMap<>()) - .put(sortKey, new ObjectMapper().createObjectNode().set("value", value)); + .put(sortKey, new ObjectMapper().createObjectNode().set("value", valueCopy)); } @Override