From 5ef3b21212ef72fea2602adb8ca0719ffe4092e5 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 6 May 2015 11:57:35 +0200 Subject: [PATCH] Add an explicit guard for root presence A modification could potentially remove the root node, which would trigger a failure in Optional.get(). Add an explicit check to provide better diagnostic in that case. Change-Id: I0e27910497169a080aa8185c66f65c9639ccf2e7 Signed-off-by: Robert Varga --- .../yang/data/impl/schema/tree/InMemoryDataTreeModification.java | 1 + 1 file changed, 1 insertion(+) diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeModification.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeModification.java index 2dda1b3f65..817110a8f1 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeModification.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeModification.java @@ -195,6 +195,7 @@ final class InMemoryDataTreeModification implements DataTreeModification { */ TreeNode originalSnapshotRoot = snapshot.getRootNode(); Optional tempRoot = strategyTree.apply(rootNode, Optional.of(originalSnapshotRoot), version); + Preconditions.checkState(tempRoot.isPresent(), "Data tree root is not present, possibly removed by previous modification"); InMemoryDataTreeSnapshot tempTree = new InMemoryDataTreeSnapshot(snapshot.getSchemaContext(), tempRoot.get(), strategyTree); return tempTree.newModification(); -- 2.36.6