Fix uninitialized ExtensionDefinition for openconfig-version 40/59240/2
authorIgor Foltin <igor.foltin@pantheon.tech>
Tue, 20 Jun 2017 14:01:17 +0000 (16:01 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 26 Jun 2017 13:58:25 +0000 (13:58 +0000)
The StatementDefinition for openconfig-version extension is
not bound to any revision. When populating the ExtensionNamespace
with openconfig-version, we have to store it with a revisionless
QName key. This way we can properly extract the corresponding
ExtensionDefinition later down the road in the
UnknownEffectiveStatementBase.

This issue causes NPE in MDSAL's binding generator v2.

Change-Id: Ie24c09b56986c87b5118d715ec6c8e755cf07ebe
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ExtensionStatementImpl.java

index 761f11c81db098a913bf6cfa4b8cfcd55b32580e..59929a10c385dd47f2f7a504995612a0520240a5 100644 (file)
@@ -63,7 +63,12 @@ public class ExtensionStatementImpl extends AbstractDeclaredStatement<QName> imp
         public void onStatementDefinitionDeclared(final StmtContext.Mutable<QName, ExtensionStatement, EffectiveStatement<QName, ExtensionStatement>> stmt) {
             super.onStatementDefinitionDeclared(stmt);
 
-            stmt.addContext(ExtensionNamespace.class, stmt.getStatementArgument(), stmt);
+            QName stmtName = stmt.getStatementArgument();
+            if (SupportedExtensionsMapping.OPENCONFIG_VERSION.getStatementName().isEqualWithoutRevision(stmtName)) {
+                stmtName = stmtName.withoutRevision();
+            }
+
+            stmt.addContext(ExtensionNamespace.class, stmtName, stmt);
 
             final StmtContext<QName, ?, ?> argument = StmtContextUtils.findFirstDeclaredSubstatement(stmt,
                 ArgumentStatement.class);