ONOS-3567 Protecting against NPE in MapValue isNewerThan
Change-Id: I8f2a46956a34d4bf50cb5b116d1c4001917daf1d
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 bb69b47..5679565 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
@@ -20,6 +20,8 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Representation of a value in EventuallyConsistentMap.
*
@@ -42,7 +44,7 @@
public MapValue(V value, Timestamp timestamp) {
this.value = value;
- this.timestamp = timestamp;
+ this.timestamp = checkNotNull(timestamp, "Timestamp cannot be null");
}
public boolean isTombstone() {
@@ -67,7 +69,10 @@
}
public boolean isNewerThan(MapValue<V> other) {
- return timestamp.isNewerThan(other.timestamp);
+ if (other == null) {
+ return true;
+ }
+ return this.timestamp.isNewerThan(other.timestamp);
}
public boolean isNewerThan(Timestamp timestamp) {