Merge "Bug 1352: Fixed issue when ModificationSnapshot was not updated during schema...
authorTony Tkacik <ttkacik@cisco.com>
Thu, 10 Jul 2014 18:18:35 +0000 (18:18 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 10 Jul 2014 18:18:35 +0000 (18:18 +0000)
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/TreeNodeUtils.java

index 6102018d48fdc918781d8acfb6c0ea774a320c8e..7013e55ad1fccdafcb4eb0c9e1550bfa9a4352df 100644 (file)
@@ -50,7 +50,7 @@ final class InMemoryDataTree implements DataTree {
     public synchronized void setSchemaContext(final SchemaContext newSchemaContext) {
         Preconditions.checkNotNull(newSchemaContext);
 
-        LOG.info("Attepting to install schema context {}", newSchemaContext);
+        LOG.info("Attempting to install schema context {}", newSchemaContext);
 
         /*
          * FIXME: we should walk the schema contexts, both current and new and see
index 5739f44743b014ce52c2874f980da4a384c32cec..5aaeb34a989f98b92bbe5213acca341d54c3d4ba 100644 (file)
@@ -11,11 +11,10 @@ import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
 
 import java.util.AbstractMap.SimpleEntry;
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
@@ -48,12 +47,16 @@ public final class TreeNodeUtils {
 
     public static <T extends StoreTreeNode<T>> T findNodeChecked(final T tree, final InstanceIdentifier path) {
         T current = tree;
-        List<PathArgument> nested = new ArrayList<>(path.getPath().size());
+
+        int i = 1;
         for(PathArgument pathArg : path.getPathArguments()) {
             Optional<T> potential = current.getChild(pathArg);
-            nested.add(pathArg);
-            Preconditions.checkArgument(potential.isPresent(),"Child %s is not present in tree.",nested);
+            if (!potential.isPresent()) {
+                throw new IllegalArgumentException(String.format("Child %s is not present in tree.",
+                        Iterables.toString(Iterables.limit(path.getPathArguments(), i))));
+            }
             current = potential.get();
+            ++i;
         }
         return current;
     }