ONOS-7007 fix parent test using wrong path

Change-Id: I666d038e3d2e33686941a99cd04a61496726f5da
This commit is contained in:
Yuta HIGUCHI 2017-09-12 13:21:13 -07:00 committed by Thomas Vachuska
parent 30161e7abe
commit ff9af3e5eb

View File

@ -107,11 +107,16 @@ public class PartitionedAsyncDocumentTree<V> implements AsyncDocumentTree<V> {
@Override @Override
public CompletableFuture<Boolean> create(DocumentPath path, V value) { 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 // 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) { if (parentValue == null) {
return Tools.exceptionalFuture(new NoSuchDocumentPathException(String.valueOf(path.parent()))); return Tools.exceptionalFuture(new NoSuchDocumentPathException(String.valueOf(path.parent())));
} else { } else {
// not atomic: parent did exist at some point, so moving forward
return partition(path).createRecursive(path, value); return partition(path).createRecursive(path, value);
} }
}); });