Junos device: Fix IllegalStateException 21/109321/2
authorYaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
Fri, 15 Dec 2023 10:05:32 +0000 (12:05 +0200)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Wed, 20 Dec 2023 11:14:37 +0000 (11:14 +0000)
To address the IllegalStateException encountered in choice processing,
an additional condition has been implemented to check if the choice has cases.
This ensures proper handling and avoids the exception.

JIRA: NETCONF-938
Change-Id: I3d1062bb5a0505944cffb1d3df1ddc80de5f7e00
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/SchemasStream.java

index 3ef816f57b371ef7d8b4572b3cd38247772d687d..c040728e347d5de7a043a6f1da721d42e1dd9cbc 100644 (file)
@@ -182,7 +182,7 @@ public final class SchemasStream extends InputStream {
                 processDataAndActionNodes(childNode, newTitle, stack, definitionNames, result, newTitle, isConfig);
             }
             stack.exit();
-        } else if (node instanceof ChoiceSchemaNode choiceNode) {
+        } else if (node instanceof ChoiceSchemaNode choiceNode && !choiceNode.getCases().isEmpty()) {
             // Process default case or first case
             final var caseNode = choiceNode.getDefaultCase()
                 .orElseGet(() -> choiceNode.getCases().stream().findFirst()