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 inconsistent equals and hashcode when annotations are cleared #573

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

popematt
Copy link
Contributor

Issue #, if available:

None

Description of changes:

The hashing of annotations was inconsistent with equals. When the _annotations array was null or an empty array, then hashTypeAnnotations would return the original hash of the value. If _annotations was a non-empty array, but all of it's elements were null (i.e. no annotations), hashTypeAnnotations() would return valueHashSalt * original.

This change moves the "return if no annotations" check until after we've counted the annotations in the array to make sure that a null or 0-size array is hashed equivalently to a null-element array.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@popematt popematt merged commit 0a4b60e into amazon-ion:master Sep 18, 2023
7 checks passed
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.

2 participants