A failure to find the SchemaNode for a path argument results in a
NullPointerException. We need the SchemaNode to understand whether it
targets an augmentation, as those need to be pruned from string output.
This patch improves the behaviour by throwing an
IllegalArgumentException with a description of which component we failed
to find.
Change-Id: I128eb63cf05b278b1af7516d426a6f0bafa87b90
Signed-off-by: Robert Varga <rovarga@cisco.com>
DataSchemaContextNode<?> current = getDataContextTree().getRoot();
for (PathArgument arg : data.getPathArguments()) {
current = current.getChild(arg);
DataSchemaContextNode<?> current = getDataContextTree().getRoot();
for (PathArgument arg : data.getPathArguments()) {
current = current.getChild(arg);
+ Preconditions.checkArgument(current != null,
+ "Invalid input %s: schema for argument %s (after %s) not found", data, arg, sb);
- if(current.isMixin()) {
+ if (current.isMixin()) {
/*
* XML/YANG instance identifier does not have concept
* of augmentation identifier, or list as whole which
/*
* XML/YANG instance identifier does not have concept
* of augmentation identifier, or list as whole which
- * identifies mixin (same as paretn element),
+ * identifies a mixin (same as the parent element),
* so we can safely ignore it if it is part of path
* (since child node) is identified in same fashion.
* so we can safely ignore it if it is part of path
* (since child node) is identified in same fashion.
*/
protected abstract @Nonnull DataSchemaContextTree getDataContextTree();
*/
protected abstract @Nonnull DataSchemaContextTree getDataContextTree();
- protected Object deserializeKeyValue(DataSchemaNode schemaNode, String value) {
+ protected Object deserializeKeyValue(final DataSchemaNode schemaNode, final String value) {