|
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.
|