Detect duplicate groupings in operation definitions 90/85990/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 26 Nov 2019 17:13:47 +0000 (18:13 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 26 Nov 2019 17:44:48 +0000 (18:44 +0100)
It seems we have been missing a namespace check here, fix that.

Change-Id: Ic6e99dfab8c6c3cfef64e519ffd84a0d6fc242a7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 10f235e5787693ee88c187782a9f37f25f45fae4)

yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveOperationDefinition.java

index 828935ac63e4bd33f0e3c657d766fb1f8e05e9c1..b3d864f471f9f114d648b50d4252c8c85351a3be 100644 (file)
@@ -44,9 +44,9 @@ public abstract class AbstractEffectiveOperationDefinition<D extends DeclaredSta
         final Set<GroupingDefinition> groupingsInit = new HashSet<>();
         final Set<TypeDefinition<?>> mutableTypeDefinitions = new LinkedHashSet<>();
         for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
-            if (effectiveStatement instanceof GroupingDefinition) {
-                // FIXME: add collision detection
-                groupingsInit.add((GroupingDefinition) effectiveStatement);
+            if (effectiveStatement instanceof GroupingDefinition
+                    && !groupingsInit.add((GroupingDefinition) effectiveStatement)) {
+                throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, effectiveStatement);
             }
             if (effectiveStatement instanceof TypedefEffectiveStatement) {
                 final TypeDefinition<?> type = ((TypedefEffectiveStatement) effectiveStatement).getTypeDefinition();