Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indeterministic hashing for BytesT #419

Conversation

buildbreaker
Copy link
Contributor

@buildbreaker buildbreaker commented Jun 30, 2023

I'm looking into different list look up use cases and found an issue with bytes. I looked into it a bit and found that what is happening is that the BytesT is calling the super.hasCode() which is unintentionally calling a hashCode() directly on an array which led to an indeterministic hashed value (it's preferred to use Arrays.hashCode(b) instead).

The change here is to change the initial value from calling super.hashCode() to just using the value 0. The alternative is to use the value Arrays.hashCode(b) if preferred.

Copy link
Member

@snazy snazy left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks!

@snazy snazy merged commit ca82288 into projectnessie:main Jul 3, 2023
4 checks passed
@buildbreaker buildbreaker deleted the achiu/fix-indeterministic-hashing-for-bytest branch July 3, 2023 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants