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

NPE in AbstractStringInstanceIdentifierCodec

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • None
    • None
    • None
    • None
    • Operating System: All
      Platform: All

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

      Attachments

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

        Activity

          People

            rovarga Robert Varga
            tpantelis Tom Pantelis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: