Fix bug: Prevent a resource with the existing ID from being registered

This resolves a part of issues found in ONOS-3827

Change-Id: I429a84b2dad7300501758f8b842dbb653e38d13b
diff --git a/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
index 5b669af..81def14 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
@@ -509,13 +509,21 @@
             return true;
         }
 
-        if (oldValues.containsAll(values)) {
+        Set<ResourceId> oldIds = oldValues.stream()
+                .map(Resource::id)
+                .collect(Collectors.toSet());
+        // values whose IDs don't match any IDs of oldValues
+        Set<Resource> addedValues = values.stream()
+                .filter(x -> !oldIds.contains(x.id()))
+                .collect(Collectors.toCollection(LinkedHashSet::new));
+        // no new ID, then no-op
+        if (addedValues.isEmpty()) {
             // don't write to map because all values are already stored
             return true;
         }
 
         LinkedHashSet<Resource> newValues = new LinkedHashSet<>(oldValues);
-        newValues.addAll(values);
+        newValues.addAll(addedValues);
         return map.replace(key, oldValues, newValues);
     }