[ 
https://issues.apache.org/jira/browse/AVRO-4182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Oscar Westra van Holthe - Kind updated AVRO-4182:
-------------------------------------------------
    Fix Version/s: 1.13.0
                   1.12.2

> NoSuchElementException in IdlReader for duplicated Enum definition
> ------------------------------------------------------------------
>
>                 Key: AVRO-4182
>                 URL: https://issues.apache.org/jira/browse/AVRO-4182
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.12.0
>            Reporter: Raphael Rösch
>            Assignee: Oscar Westra van Holthe - Kind
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.13.0, 1.12.2
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Given this avdl (TestProtocol.avdl):
> {noformat}
> protocol TestProtocol {
>   enum Foo {
>     UNKNOWN,
>     BAR
>   } = UNKNOWN;
>   enum Foo {
>     UNKNOWN,
>     BAZ
>   } = UNKNOWN;
> }
> {noformat}
> With Avro 1.12.0 'IdlReader' fails with NoSuchElementException
> {noformat}
> $ java -jar ./avro-tools-1.12.0.jar idl ./TestProtocol.avdl
> Exception in thread "main" org.apache.avro.SchemaParseException: 
> java.util.NoSuchElementException
>       at org.apache.avro.idl.IdlReader.parse(IdlReader.java:224)
>       at org.apache.avro.idl.IdlReader.parse(IdlReader.java:187)
>       at org.apache.avro.idl.IdlReader.parse(IdlReader.java:172)
>       at org.apache.avro.tool.IdlTool.run(IdlTool.java:70)
>       at org.apache.avro.tool.Main.run(Main.java:67)
>       at org.apache.avro.tool.Main.main(Main.java:56)
> Caused by: java.util.NoSuchElementException
>       at java.base/java.util.ArrayDeque.removeFirst(ArrayDeque.java:360)
>       at java.base/java.util.ArrayDeque.pop(ArrayDeque.java:591)
>       at 
> org.apache.avro.idl.IdlReader$IdlParserListener.exitEnumDeclaration(IdlReader.java:531)
>       at 
> org.apache.avro.idl.IdlParser$EnumDeclarationContext.exitRule(IdlParser.java:976)
>       at org.antlr.v4.runtime.Parser.triggerExitRuleEvent(Parser.java:410)
>       at org.antlr.v4.runtime.Parser.exitRule(Parser.java:642)
>       at org.apache.avro.idl.IdlParser.idlFile(IdlParser.java:289)
>       at org.apache.avro.idl.IdlReader.parse(IdlReader.java:220)
>       ... 5 more
> {noformat}
> * This does also happen if the Enums are defined in two different Protocols 
> of the same namespace.
> * Having multiple Enums of the same name should not be allowed. The parse 
> must therefore fail, but print a more helpful error message.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to