The 'nested' array should be initialized as empty, but sized for
the size of path.getPath(), as we fill it continuously as we traverse
the tree.
The original initialization also copied path.getPath(), resulting in the
path reported in full and then correctly.
Change-Id: I9a918ced62a845b985459699e23f1f2f1d55cf35
Signed-off-by: Robert Varga <rovarga@cisco.com>
public static <T extends StoreTreeNode<T>> T findNodeChecked(final T tree, final InstanceIdentifier path) {
T current = tree;
public static <T extends StoreTreeNode<T>> T findNodeChecked(final T tree, final InstanceIdentifier path) {
T current = tree;
- List<PathArgument> nested = new ArrayList<>(path.getPath());
+ List<PathArgument> nested = new ArrayList<>(path.getPath().size());
for(PathArgument pathArg : path.getPath()) {
Optional<T> potential = current.getChild(pathArg);
nested.add(pathArg);
for(PathArgument pathArg : path.getPath()) {
Optional<T> potential = current.getChild(pathArg);
nested.add(pathArg);