diff --git a/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java b/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java index 7ecfbe58b1..23e2e5f1f3 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java +++ b/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java @@ -314,7 +314,7 @@ public class EventuallyConsistentMapImpl checkState(!destroyed, destroyedMessage); checkNotNull(key, ERROR_NULL_KEY); // TODO prevent calls here if value is important for timestamp - MapValue tombstone = new MapValue<>(null, timestampProvider.apply(key, null)); + MapValue tombstone = MapValue.tombstone(timestampProvider.apply(key, null)); MapValue previousValue = removeInternal(key, Optional.empty(), tombstone); if (previousValue != null) { notifyPeers(new UpdateEntry<>(key, tombstone), peerUpdateFunction.apply(key, previousValue.get())); @@ -330,7 +330,7 @@ public class EventuallyConsistentMapImpl checkState(!destroyed, destroyedMessage); checkNotNull(key, ERROR_NULL_KEY); checkNotNull(value, ERROR_NULL_VALUE); - MapValue tombstone = new MapValue<>(null, timestampProvider.apply(key, value)); + MapValue tombstone = MapValue.tombstone(timestampProvider.apply(key, value)); MapValue previousValue = removeInternal(key, Optional.of(value), tombstone); if (previousValue != null) { notifyPeers(new UpdateEntry<>(key, tombstone), peerUpdateFunction.apply(key, previousValue.get())); @@ -561,7 +561,7 @@ public class EventuallyConsistentMapImpl if (remoteValueDigest != null && remoteValueDigest.isTombstone()) { MapValue previousValue = removeInternal(key, Optional.empty(), - new MapValue<>(null, remoteValueDigest.timestamp())); + MapValue.tombstone(remoteValueDigest.timestamp())); if (previousValue != null && previousValue.isAlive()) { externalEvents.add(new EventuallyConsistentMapEvent<>(REMOVE, key, previousValue.get())); } diff --git a/core/store/dist/src/main/java/org/onosproject/store/ecmap/MapValue.java b/core/store/dist/src/main/java/org/onosproject/store/ecmap/MapValue.java index 922556109a..aa5796249d 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/ecmap/MapValue.java +++ b/core/store/dist/src/main/java/org/onosproject/store/ecmap/MapValue.java @@ -12,6 +12,17 @@ public class MapValue implements Comparable> { private final Timestamp timestamp; private final V value; + /** + * Creates a tombstone value with the specified timestamp. + * @param timestamp timestamp for tombstone + * @return tombstone MapValue + * + * @param value type + */ + public static MapValue tombstone(Timestamp timestamp) { + return new MapValue<>(null, timestamp); + } + public MapValue(V value, Timestamp timestamp) { this.value = value; this.timestamp = timestamp;