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

Default of a union in YANG 1.1 only processed correctly if corresponds to first member type

    XMLWordPrintable

Details

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

    • 8831

    Description

      When a leaf has a union type, and a default that does not correspond to the first member of that union type, the default is not processed correctly. The attached model gives an error:

      Caused by: org.opendaylight.yangtools.yang.parser.spi.source.SourceException: Unable to find a default value for leaf '(http://www.example.com?revision=2017-07-10)enum-last-leaf' [at example-model:35:4]
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.LeafEffectiveStatementImpl.(LeafEffectiveStatementImpl.java:67)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.LeafStatementImpl$Definition.createEffective(LeafStatementImpl.java:79)
      at org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase.buildEffective(StatementContextBase.java:408)
      at com.google.common.collect.Iterators$8.transform(Iterators.java:799)
      at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
      at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
      at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:258)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase.(EffectiveStatementBase.java:56)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase.(DeclaredEffectiveStatementBase.java:32)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveDocumentedNode.(AbstractEffectiveDocumentedNode.java:30)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveDocumentedDataNodeContainer.(AbstractEffectiveDocumentedDataNodeContainer.java:45)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveSimpleDataNodeContainer.(AbstractEffectiveSimpleDataNodeContainer.java:47)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveContainerSchemaNode.(AbstractEffectiveContainerSchemaNode.java:21)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ContainerEffectiveStatementImpl.(ContainerEffectiveStatementImpl.java:32)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.ContainerStatementImpl$Definition.createEffective(ContainerStatementImpl.java:86)
      at org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase.buildEffective(StatementContextBase.java:408)
      at com.google.common.collect.Iterators$8.transform(Iterators.java:799)
      at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
      at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
      at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:258)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase.(EffectiveStatementBase.java:56)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase.(DeclaredEffectiveStatementBase.java:32)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveDocumentedNode.(AbstractEffectiveDocumentedNode.java:30)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveModule.(AbstractEffectiveModule.java:86)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ModuleEffectiveStatementImpl.(ModuleEffectiveStatementImpl.java:23)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.ModuleStatementSupport.createEffective(ModuleStatementSupport.java:100)
      at org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase.buildEffective(StatementContextBase.java:408)
      at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.transformEffective(BuildGlobalContext.java:250)
      ... 80 more
      Caused by: java.lang.IllegalStateException: Unable to find following default values [any]
      at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils.isAnyDefaultValueMarkedWithIfFeature(TypeUtils.java:305)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils.isAnyDefaultValueMarkedWithIfFeature(TypeUtils.java:300)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils.isAnyDefaultValueMarkedWithIfFeature(TypeUtils.java:300)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils.hasDefaultValueMarkedWithIfFeature(TypeUtils.java:277)
      at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.LeafEffectiveStatementImpl.(LeafEffectiveStatementImpl.java:61)
      ... 107 more

      This is because TypeUtils.isAnyDefaultValueMarkedWithIfFeature is called recursively, but bails out after the first member type of the union.

      Attachments

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

        Activity

          People

            pkajsa Peter Kajsa
            verthezpw Peter Verthez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: