Skip to content

AVRO-3235: [java] Add regression test for enum resolution across namespaces - #3952

Open
iemejia wants to merge 2 commits into
apache:mainfrom
iemejia:AVRO-3235-enum-namespace-resolution-test
Open

AVRO-3235: [java] Add regression test for enum resolution across namespaces#3952
iemejia wants to merge 2 commits into
apache:mainfrom
iemejia:AVRO-3235-enum-namespace-resolution-test

Conversation

@iemejia

@iemejia iemejia commented Aug 23, 2026

Copy link
Copy Markdown
Member

What

AVRO-3235 reported that schema evolution crashed when a record/enum kept the same simple name but changed namespace across versions (a common versioning pattern). The underlying behaviour has since been fixed — the resolver matches enums by their simple name (Resolver.EnumAdjust.resolve uses getName()), so cross-namespace enums resolve correctly. But there was no dedicated regression test for that case.

I reproduced the original scenario on current main and confirmed it works (v1 record read by a v2 reader: the enum resolves and the added field takes its default). This PR locks that in.

Test

Adds TestResolver.resolveEnumAcrossNamespaces:

  • asserts the enum action is an EnumAdjust (not a NAMES_DONT_MATCH error) for test.v1.Statustest.v2.Status;
  • does a full binary round-trip: writer record test.v1.Simple → reader record test.v2.Simple with an extra defaulted description field, asserting the enum resolves and the default is inserted.

This guards against a regression, which is especially relevant given the related tension around name-vs-fullname matching (AVRO-3703).

Closes AVRO-3235.

JIRA: https://issues.apache.org/jira/browse/AVRO-3235

…e conversions

Every explicit IConvertible.ToXxx(IFormatProvider) implementation on
AvroDecimal called Convert.ToXxx(this, provider). Because 'this' is an
IConvertible, Convert.ToXxx(IConvertible, provider) calls back into the same
IConvertible.ToXxx(provider) method, recursing until a StackOverflowException
(which is uncatchable and crashes the process). Reproducer:
Convert.ToByte(new AvroDecimal(0)).

Route the 12 numeric/boolean conversions through IConvertible.ToType(type,
provider) (the one method that performs the real conversion via
Convert.ChangeType on the underlying decimal), and make ToString(provider)
use the public ToString() override. Adds a test exercising all conversions.
…spaces

Enums (and their enclosing records) that share the same simple name but live
in different namespaces must still resolve, so data versioned by namespace
stays backward/forward compatible. This behaviour is already correct in the
resolver (enum matching uses the simple name), but there was no dedicated
regression test for the cross-namespace case reported in AVRO-3235.

Adds resolveEnumAcrossNamespaces: asserts the enum action is an EnumAdjust
(not NAMES_DONT_MATCH) and does a full v1 -> v2 record round-trip where the
reader adds a defaulted field, confirming the enum resolves and the default
is inserted.
@github-actions github-actions Bot added Java Pull Requests for Java binding C# labels Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C# Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant