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

NoSuchElementException during java binding generation from yang model with choice in module body at top level

    XMLWordPrintable

Details

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

    • 2333

    Description

      BindingGeneratorImpl fails during java source code generation from yang model witch contains choice element directly in module body at top level.

      For an example:
      module choice-test {
      yang-version 1;
      namespace "uri:choice-test";
      prefix tst;

      revision 2014-10-07

      { description "Choice test."; }

      choice my-choice {
      case one {
      leaf my-choice-leaf-one

      { type string; }

      }
      case two {
      leaf my-choice-leaf-two

      { type int16; }

      }
      }
      }

      This is because the line 1213 and 1214 in BindingGeneratorImpl.java class:
      final SchemaPath nodeSp = choiceNode.getPath();
      final Object parentNode = findDataSchemaNode(schemaContext, nodeSp.getParent());

      The parent path of choice element is empty (because parent is module) and therefore iterator.next() on the path fails.

      Exception stack trace:
      Unable to generate sources with org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl generator
      java.util.NoSuchElementException
      at com.google.common.collect.Iterators$1.next(Iterators.java:71)
      at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeInSchemaContext(SchemaContextUtil.java:252)
      at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode(SchemaContextUtil.java:83)
      at org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl.generateTypesFromChoiceCases(BindingGeneratorImpl.java:1215)
      at org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl.choiceToGeneratedType(BindingGeneratorImpl.java:1161)
      at org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl.addSchemaNodeToBuilderAsMethod(BindingGeneratorImpl.java:1117)
      at org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl.resolveDataSchemaNodes(BindingGeneratorImpl.java:1046)
      at org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl.moduleToGenTypes(BindingGeneratorImpl.java:268)
      at org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl.generateTypes(BindingGeneratorImpl.java:237)
      at org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl.generateSources(CodeGeneratorImpl.java:62)

      ....

      Attachments

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

        Activity

          People

            pkajsa Peter Kajsa
            pkajsa Peter Kajsa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: