-
Bug
-
Resolution: Won't Do
-
High
-
None
-
7.0.14
-
None
NormalizedNodeStreamWriterStack fails to initialize on
choice nodes because ChoiceEffectiveStatementImpl is not an instance of DataContainerNode.
This happens when trying to create Nested writers in both JSONNormalizedNodeStreamWriter and XMLNormalizedNodeStreamWriter.
This is the node I was trying to create Nested writer for:
AbsoluteSchemaPath{path=[(urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)network-topology, (urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)topology, (urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)node, (urn:opendaylight:netconf-node-topology?revision=2015-01-14)credentials, (urn:opendaylight:netconf-node-topology?revision=2015-01-14)username]}AbsoluteSchemaPath{path=[(urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)network-topology, (urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)topology, (urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)node, (urn:opendaylight:netconf-node-topology?revision=2015-01-14)credentials, (urn:opendaylight:netconf-node-topology?revision=2015-01-14)username]}
The provided SchemaPath for that node looks as following:
AbsoluteSchemaPath{path=[(urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)network-topology, (urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)topology, (urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)node, (urn:opendaylight:netconf-node-topology?revision=2015-01-14)credentials]}
Now I believe while serializing choice nodes, we should be able to initialize on the parent
of that choice node, ie credentials in this case.
If we should supply even one level higher, ie node in this case, this would require users to map the SchemaPath nodes against tree to just validate this one case and adjust the path accordingly.
Then I consider this behavior as inconsistent.
I would expect this code snippet to work for choice nodes as well:
final SchemaPath path = SchemaPath.create(nodePath.stream() .filter(p -> !(p instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates)) .filter(p -> !(p instanceof YangInstanceIdentifier.AugmentationIdentifier)) .map(YangInstanceIdentifier.PathArgument::getNodeType).collect(Collectors.toList()), true); final NormalizedNodeStreamWriter nestedWriter = JSONNormalizedNodeStreamWriter .createNestedWriter(codecSupplier.getShared(context), path.getParent(), null, jsonWriter);
Correct me if I am using this wrong.
- split to
-
YANGTOOLS-1402 Consider adding YangInstanceIdentifier+NormalizedNode-based codec utilities
- Confirmed