fixing side effect of mutabilty od resource id
Change-Id: I16bf790829e1c9984e61eb8bf5d5754b1c6ab001
diff --git a/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java b/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java
index 802e682..6bcdecc 100755
--- a/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java
+++ b/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java
@@ -17,6 +17,7 @@
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import org.onosproject.yang.model.KeyLeaf;
@@ -46,12 +47,6 @@
}
- public static ResourceId getParent(ResourceId path) {
- int last = path.nodeKeys().size();
- path.nodeKeys().remove(last - 1);
- return path;
- }
-
public static NodeKey getInstanceKey(ResourceId path) {
int last = path.nodeKeys().size();
NodeKey ret = path.nodeKeys().get(last - 1);
@@ -92,7 +87,6 @@
return ret;
}
-
public static String appendMultiInstKey(String path, String leaf) {
return (path + leaf.substring(leaf.indexOf(KEY_SEP)));
}
@@ -161,7 +155,14 @@
if (path == null) {
return bldr.toString();
}
- List<NodeKey> nodeKeyList = path.nodeKeys();
+ List<NodeKey> nodeKeyList = new LinkedList<>();
+ Iterator<NodeKey> itr = path.nodeKeys().iterator();
+ while (itr.hasNext()) {
+ nodeKeyList.add(itr.next());
+ }
+ if (nodeKeyList.get(0).schemaId().name().compareTo("/") == 0) {
+ nodeKeyList.remove(0);
+ }
for (NodeKey key : nodeKeyList) {
bldr.append(EL_SEP);
if (key instanceof LeafListKey) {