null tolerant DocumentPath hasher
- DocumentPath parent can be null
Change-Id: If0daf8f05db47f532e406c9879ff94ce72693791
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/FederatedDistributedPrimitiveCreator.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/FederatedDistributedPrimitiveCreator.java
index b7bb8f6..8d5668f 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/FederatedDistributedPrimitiveCreator.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/FederatedDistributedPrimitiveCreator.java
@@ -147,7 +147,7 @@
Map<PartitionId, AsyncDocumentTree<V>> trees =
Maps.transformValues(members, partition -> partition.<V>newAsyncDocumentTree(name, serializer));
Hasher<DocumentPath> hasher = key -> {
- int bucket = Math.abs(Hashing.murmur3_32().hashUnencodedChars(key.toString()).asInt()) % buckets;
+ int bucket = Math.abs(Hashing.murmur3_32().hashUnencodedChars(String.valueOf(key)).asInt()) % buckets;
return sortedMemberPartitionIds.get(Hashing.consistentHash(bucket, sortedMemberPartitionIds.size()));
};
return new PartitionedAsyncDocumentTree<>(name, trees, hasher);
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/PartitionedAsyncDocumentTree.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/PartitionedAsyncDocumentTree.java
index 3c53e30..2d17282 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/PartitionedAsyncDocumentTree.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/PartitionedAsyncDocumentTree.java
@@ -110,7 +110,7 @@
// TODO: This operation is not atomic
return partition(path.parent()).get(path).thenCompose(parentValue -> {
if (parentValue == null) {
- return Tools.exceptionalFuture(new NoSuchDocumentPathException(path.parent().toString()));
+ return Tools.exceptionalFuture(new NoSuchDocumentPathException(String.valueOf(path.parent())));
} else {
return partition(path).createRecursive(path, value);
}