Skip to content

AVRO-4265: [java] Defer forward default checks - #4048

Open
skyon0522-ai wants to merge 1 commit into
apache:mainfrom
skyon0522-ai:codex/avro-4265-forward-defaults
Open

skyon0522-ai wants to merge 1 commit into
apache:mainfrom
skyon0522-ai:codex/avro-4265-forward-defaults

Conversation

@skyon0522-ai

Copy link
Copy Markdown

What is the purpose of the change

Fix AVRO-4265. Parsing a record before its referenced enum currently rejects a valid enum field default against the unresolved record placeholder.

Reuse the schema-readiness check already used by the IDL reader, and validate defaults after unresolved references have been replaced. Fully resolved types keep eager validation, and the existing validation opt-out is preserved. Skip the readiness walk when default validation is disabled or no default is present.

Verifying this change

This change adds tests for both record/enum parse orders, retained and aggregate schema identities, invalid defaults after resolution, eager validation of known types, the legacy opt-out, unresolved names, and nullable cross-file cycles.

The valid forward enum case failed on the original production code. The invalid enum case also failed prematurely while parsing, rather than at final resolution. Both pass with this change, while the other controls retain their behavior.

On Linux, the selected TestSchema, TestSchemaParser, and TestSchemaBuilder tests passed under all three configurations: 113 cases per configuration, or 339 test-case executions in total, with no failures, errors or skipped cases. Maven 3.9.11 launched on JDK 21; the unchanged project toolchain configuration selected JDK 17.0.20.1 for compilation and tests. Spotless and Checkstyle passed.

The root install lifecycle, run without global test or quality skip flags, also passed across all 27 reactor projects, including the core Invoker builds on JDK 11, 17 and 21. The upstream test -Phadoop2 command passed all 27 projects using Hadoop 2.10.1. Existing test skips remain; the Hadoop 2 command covers the test phase.

The separate existing limitation involving finite object defaults across circular references is outside this fix; nullable cycles are covered.

Documentation

  • Does this pull request introduce a new feature? No.
  • If yes, how is the feature documented? Not applicable.

Keep valid enum defaults from being checked against unresolved record
placeholders. Preserve eager validation for resolved types and the
existing validation opt-out, without traversing types that need no
default check.

Cover both parse orders, default rejection, and shared schema
identities.

Assisted-by: OpenAI Codex
@github-actions github-actions Bot added the Java Pull Requests for Java binding label Oct 18, 2026
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.

1 participant