[ONOS-7372] GossipDeviceStore cannot do 'mark off line' for a removed device in a controller recovered from failure
Change-Id: If566cfa6af376b2792cd8b978189a885e28ec89c
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
index 6726319..faaed09 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
@@ -481,17 +481,15 @@
// accept off-line if given timestamp is newer than
// the latest Timestamp from Primary provider
DeviceDescriptions primDescs = getPrimaryDescriptions(providerDescs);
- if (primDescs == null) {
- return null;
- }
-
- Timestamp lastTimestamp = primDescs.getLatestTimestamp();
- if (lastTimestamp == null) {
- lastTimestamp = deviceClockService.getTimestamp(deviceId);
- }
- if (timestamp.compareTo(lastTimestamp) <= 0) {
- // outdated event ignore
- return null;
+ if (primDescs != null) {
+ Timestamp lastTimestamp = primDescs.getLatestTimestamp();
+ if (lastTimestamp == null) {
+ lastTimestamp = deviceClockService.getTimestamp(deviceId);
+ }
+ if (timestamp.compareTo(lastTimestamp) <= 0) {
+ // outdated event ignore
+ return null;
+ }
}
offline.put(deviceId, timestamp);
@@ -1449,8 +1447,7 @@
// checking if remote timestamp is more recent.
Timestamp rOffline = offlineAds.get(deviceId);
- if (rOffline != null &&
- rOffline.compareTo(localLatest) > 0) {
+ if (localLatest == null || (rOffline != null && rOffline.compareTo(localLatest) > 0)) {
// remote offline timestamp suggests that the
// device is off-line
markOfflineInternal(deviceId, rOffline);