Do not issue immediate build when looking up grouping 89/82089/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 15 May 2019 11:52:34 +0000 (13:52 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 15 May 2019 13:10:19 +0000 (15:10 +0200)
If we fail to find a grouping, we will end up with a NPE which
does not provide any information. Move the .build() call so that
the proper ISE kicks in.

JIRA: MDSAL-448
Change-Id: I57d6a74074b49def9bbc814732cfc48cd5265072
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e802061e56eea9779e13eede5f949aa96666ea28)

binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypeGenerator.java

index d8a583533489f5a4a14e78c2eec2c65f77f256c5..654da77948fa5b84706be9ea99914d0567725357 100644 (file)
@@ -2033,13 +2033,13 @@ abstract class AbstractTypeGenerator {
     private GeneratedTypeBuilder addImplementedInterfaceFromUses(final DataNodeContainer dataNodeContainer,
             final GeneratedTypeBuilder builder) {
         for (final UsesNode usesNode : dataNodeContainer.getUses()) {
-            final GeneratedType genType = findGroupingByPath(usesNode.getGroupingPath()).build();
+            final GeneratedTypeBuilder genType = findGroupingByPath(usesNode.getGroupingPath());
             if (genType == null) {
                 throw new IllegalStateException("Grouping " + usesNode.getGroupingPath() + "is not resolved for "
                         + builder.getName());
             }
 
-            builder.addImplementsType(genType);
+            builder.addImplementsType(genType.build());
         }
         return builder;
     }