Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-1401

NormalizedNodeStreamWriterStack fails to initialize on choice nodes

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • High
    • Resolution: Won't Do
    • 7.0.14
    • None
    • data-util
    • None

    Description

      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.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Unassigned Unassigned
              ppuskar Peter Puškár
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: