Skip to content

AVRO-4322: [Java] Use reader/writers constently with model - #3924

Merged
RyanSkraba merged 1 commit into
apache:mainfrom
RyanSkraba:rskraba/AVRO-4322-consistent-model
Aug 6, 2026
Merged

AVRO-4322: [Java] Use reader/writers constently with model#3924
RyanSkraba merged 1 commit into
apache:mainfrom
RyanSkraba:rskraba/AVRO-4322-consistent-model

Conversation

@RyanSkraba

Copy link
Copy Markdown
Contributor

What is the purpose of the change

We should be using the GenericDatumReader and SpecificDatumReader with the respective models. The mix causes a test failure with fastread.

Verifying this change

This change is already covered by existing tests, such as FastReaderBuilderJavaClassTest.

Documentation

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

@github-actions github-actions Bot added the Java Pull Requests for Java binding label Aug 6, 2026
@RyanSkraba RyanSkraba changed the title AVRO-4322: Use reader/writers constently with model AVRO-4322: [Java] Use reader/writers constently with model Aug 6, 2026
@RyanSkraba
RyanSkraba force-pushed the rskraba/AVRO-4322-consistent-model branch from af2ee0b to 33b8f8a Compare August 6, 2026 13:30
MyReader() {
// Use a new data model instead of the singleton in order to avoid modifying the
// setFastReaderEnabled state for other tests.
super(null, null, new SpecificData());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, it looks like this was a hidden bug -- if we setFastReaderEnabled(true) or setFastReaderEnabled(false) on the singleton instance of SpecificData, it overrides the system property and in other tests we end up not testing what we thought we were testing...

I checked through the code and this looks like the only spot where it gets changed in the singleton.

@iemejia iemejia Aug 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh wow, that's a bit weird so we were not really testing everything correctly ufff. Oh wait that's Test specific, I see now.

@iemejia iemejia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for figuring out the reason. It was far from trivial. What about other subclasses, or is this the only one?

MyReader() {
// Use a new data model instead of the singleton in order to avoid modifying the
// setFastReaderEnabled state for other tests.
super(null, null, new SpecificData());

@iemejia iemejia Aug 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh wow, that's a bit weird so we were not really testing everything correctly ufff. Oh wait that's Test specific, I see now.

@RyanSkraba

Copy link
Copy Markdown
Contributor Author

I checked, and this was the only instance I found, but I raised https://issues.apache.org/jira/browse/AVRO-4326 to find a strategy to make sure we don't introduce new instances.

@RyanSkraba
RyanSkraba merged commit 42e4c3d into apache:main Aug 6, 2026
9 checks passed
@RyanSkraba
RyanSkraba deleted the rskraba/AVRO-4322-consistent-model branch August 6, 2026 15:24
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