aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java')
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
index 82dfe32f..4d9e3cbf 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
@@ -292,9 +292,9 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
* @return true if the operation succeeds, false otherwise.
*/
private <K, V> boolean appendValues(TransactionalMap<K, List<V>> map, K key, List<V> values) {
- List<V> oldValues = map.get(key);
+ List<V> oldValues = map.putIfAbsent(key, new ArrayList<>(values));
if (oldValues == null) {
- return map.replace(key, oldValues, new ArrayList<>(values));
+ return true;
}
LinkedHashSet<V> oldSet = new LinkedHashSet<>(oldValues);
@@ -321,7 +321,8 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
private <K, V> boolean removeValues(TransactionalMap<K, List<V>> map, K key, List<V> values) {
List<V> oldValues = map.get(key);
if (oldValues == null) {
- return map.replace(key, oldValues, new ArrayList<>());
+ map.put(key, new ArrayList<>());
+ return true;
}
LinkedHashSet<V> oldSet = new LinkedHashSet<>(oldValues);