Skip to content

Conversation

@steven-aerts
Copy link
Contributor

The generated hashCode function has a local parameter called result. To prevent this local variable to conflict with field which have the same name, it has to refer to the fields with this.<fieldName> making it unambiguous refer to fields and not local variables.

What is the purpose of the change

Fix a name collision in the generated hashCode function reported in AVRO-4202

Verifying this change

This change is a trivial rework I also manually verified. Let me know if you want an extra test.

Documentation

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

The generated hashCode function has a local parameter called result.
To prevent this local variable to conflict with field which have the
same name, it has to refer to the fields with `this.<fieldName>` making
it unambiguous refer to fields and not local variables.
@github-actions github-actions bot added the Java Pull Requests for Java binding label Nov 14, 2025
@RyanSkraba RyanSkraba changed the title AVRO-4202 refer to fields for generated hashCode AVRO-4202: Refer to fields for generated hashCode Nov 14, 2025
@RyanSkraba RyanSkraba merged commit 3b06d5e into apache:main Nov 14, 2025
9 checks passed
RyanSkraba pushed a commit that referenced this pull request Nov 14, 2025
The generated hashCode function has a local parameter called result.
To prevent this local variable to conflict with field which have the
same name, it has to refer to the fields with `this.<fieldName>` making
it unambiguous refer to fields and not local variables.
@RyanSkraba
Copy link
Contributor

Thanks so much for this fix! It should be included in the next minor release.
Cherry-picked to branch-1.12.

Let me know if you want me to assign you this JIRA! I've marked it as Resolved, but I didn't find an account for you.

@steven-aerts
Copy link
Contributor Author

@RyanSkraba thanks a lot for cherry picking.
My apache account is steven.aerts. I cannot assign it to myself anymore as its state is Resolved. Do not worry for me it is okay as it is.

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.

3 participants