Raphael Rösch created AVRO-4182:
-----------------------------------
Summary: 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
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)