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 equality check of timevalue after serialization #9218

Closed
wants to merge 1 commit into from
Closed

Fix equality check of timevalue after serialization #9218

wants to merge 1 commit into from

Conversation

mfelsche
Copy link

@mfelsche mfelsche commented Jan 9, 2015

TimeValue serialization changes timeUnit to NANOSECONDS and converts duration accordingly.
As .equals() and .hashCode() blindly compare those properties, equality is not conserved during serialization.

if (duration != timeValue.duration) return false;
if (timeUnit != timeValue.timeUnit) return false;

if (timeUnit.toNanos(duration) != timeValue.timeUnit.toNanos(timeValue.duration)) {
Copy link
Member

Choose a reason for hiding this comment

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

This, plus the final return, can be simplified to just return the value of an == comparison between the two values.

Copy link
Author

Choose a reason for hiding this comment

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

yeah, my IDE told me the same, and i didn't listen. shame on me.

@mfelsche
Copy link
Author

mfelsche commented Mar 6, 2015

Sorry, i completely forgot about this PR.
Rebased on master.

@rjernst
Copy link
Member

rjernst commented Mar 6, 2015

Thanks @mfelsche!

@clintongormley clintongormley changed the title fix equality check of timevalue after serialization Fix equality check of timevalue after serialization Jun 7, 2015
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants