Skip to content

AVRO-4182: Avoid ANTLR parsing edge cases#3756

Merged
opwvhk merged 3 commits into
apache:mainfrom
opwvhk:avro-4182-avoid-antlr-edge-cases
May 15, 2026
Merged

AVRO-4182: Avoid ANTLR parsing edge cases#3756
opwvhk merged 3 commits into
apache:mainfrom
opwvhk:avro-4182-avoid-antlr-edge-cases

Conversation

@opwvhk
Copy link
Copy Markdown
Contributor

@opwvhk opwvhk commented May 3, 2026

What is the purpose of the change

In some cases, enter and exit rules are not called in pairs. Apparently, this is by design. This fix adds a test that the fix does indeed work (it tests an exception, as the error does not show up with a duplicated definition).

Note: this change keeps the entire parse tree in memory during parsing, and allows it to be collected directly afterwards.

This PR fixes the bug reported as AVRO-4182.

Verifying this change

This change adds a test: org.apache.avro.idl.TestIdlReader#testErrorDuplicateNamedType()

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

In some cases, enter and exit rules are not called in pairs. Apparently,
this is by design. This fix adds a test that the fix does indeed work
(it tests an exception, as the error does not show up with a duplicated
definition).

Note: this change keeps the entire parse tree in memory during parsing,
and allows it to be collected directly afterwards.
@github-actions github-actions Bot added the Java Pull Requests for Java binding label May 3, 2026
parser.removeErrorListeners();
parser.addErrorListener(SIMPLE_AVRO_ERROR_LISTENER);
parser.addParseListener(parseListener);
// parser.addParseListener(parseListener);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove this line.

@opwvhk opwvhk merged commit 34bdcf9 into apache:main May 15, 2026
9 checks passed
@opwvhk opwvhk deleted the avro-4182-avoid-antlr-edge-cases branch May 15, 2026 16:55
opwvhk added a commit that referenced this pull request May 15, 2026
In some cases, enter and exit rules are not called in pairs while parsing.
Apparently, this is by design. This fix adds a test that the fix does indeed
work (it tests an exception, as the error does not show up with a duplicated
definition).

Note: this change keeps the entire parse tree in memory during parsing,
and allows it to be collected directly afterwards.

(cherry picked from commit 34bdcf9)
@opwvhk
Copy link
Copy Markdown
Contributor Author

opwvhk commented May 15, 2026

Cherry-picked to 1.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants