commit | ff9af3e5ebcf48f8aa454c0d0f49c8f5677387db | [log] [tgz] |
---|---|---|
author | Yuta HIGUCHI <y-higuchi@ak.jp.nec.com> | Tue Sep 12 13:21:13 2017 -0700 |
committer | Thomas Vachuska <tom@opennetworking.org> | Fri Sep 15 15:14:25 2017 +0000 |
tree | 90c135ba3d32d0a6d73d7fb4f73f4664dc0e555a | |
parent | 30161e7abec0b2ae63d029f07f542db73cca6de3 [diff] |
ONOS-7007 fix parent test using wrong path Change-Id: I666d038e3d2e33686941a99cd04a61496726f5da
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 2d17282..71758a0 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
@@ -107,11 +107,16 @@ @Override public CompletableFuture<Boolean> create(DocumentPath path, V value) { + if (path.parent() == null) { + // create value on root + return partition(path).createRecursive(path, value); + } // TODO: This operation is not atomic - return partition(path.parent()).get(path).thenCompose(parentValue -> { + return partition(path.parent()).get(path.parent()).thenCompose(parentValue -> { if (parentValue == null) { return Tools.exceptionalFuture(new NoSuchDocumentPathException(String.valueOf(path.parent()))); } else { + // not atomic: parent did exist at some point, so moving forward return partition(path).createRecursive(path, value); } });