[YANGTOOLS-489] NPE in AbstractStringInstanceIdentifierCodec Created: 18/Aug/15  Updated: 10/Apr/22  Resolved: 14/Sep/15

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Tom Pantelis Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 4154
Priority: Normal

 Description   

I have a data model with an instance-identifier leaf however the YangInstanceIdentifier value did not conform to a valid schema. This resulted in an NPE in AbstractStringInstanceIdentifierCodec#serialize at line 36:

@Override
public final String serialize(final YangInstanceIdentifier data) {
StringBuilder sb = new StringBuilder();
DataSchemaContextNode<?> current = getDataContextTree().getRoot();
for (PathArgument arg : data.getPathArguments()) {
current = current.getChild(arg); <--- line 36

if(current.isMixin())

{ /* * XML/YANG instance identifier does not have concept * of augmentation identifier, or list as whole which * identifies mixin (same as paretn element), * so we can safely ignore it if it is part of path * (since child node) is identified in same fashion. * */ continue; }

...
}
}

It looks like the rest of the code would work OK w/o the isMixin() check since the ID doesn't have a backing schema so it could check for null "current" and ignore. However if the intent is for leaf instance-identifier values to correspond to a valid path/schema in the tree, then we should emit an exception (eg IllegalArgumentException) with useful context in the message.



 Comments   
Comment by Robert Varga [ 13/Sep/15 ]

https://git.opendaylight.org/gerrit/26895

Generated at Wed Feb 07 20:53:24 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.