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

Review WhatsApp Message compareTo() to avoid "Comparison method violates its general contract" exceptions. #2338

Merged
merged 4 commits into from
Oct 15, 2024

Conversation

wladimirleite
Copy link
Member

Fix #2337.

@wladimirleite wladimirleite marked this pull request as draft October 15, 2024 15:19
@wladimirleite
Copy link
Member Author

I just noticed that there is a test case failing after this fix.
For now, I converted it to draft and will push a fix shortly.

@wladimirleite wladimirleite marked this pull request as ready for review October 15, 2024 16:32
@wladimirleite
Copy link
Member Author

Unit tests are working again.
I tested with 4 database samples (Android old, new, iOS and an Android that I have the device here), and the result seems fine.

@lfcnassif
Copy link
Member

Thank you @wladimirleite! Just to confirm commit 39c1a37 is good, right?

@wladimirleite
Copy link
Member Author

Thank you @wladimirleite! Just to confirm commit 39c1a37 is good, right?

No! Sorry, I will fix it.

@wladimirleite
Copy link
Member Author

Thank you @wladimirleite! Just to confirm commit 39c1a37 is good, right?

No! Sorry, I will fix it.

I believe it is correct (and a bit clearer) now.
I am sorry for the last wrong commits, @lfcnassif...
I was doing other things in parallel and messed up.

Priority order should be: sortId -> timeStamp -> id.
For new databases, sortId is usually present in all records. For older ones, no sortId, but timeStamp is always present.
In practice, the fallback is only used in very specific cases, only between sortId and timeStamp.

Copy link
Member

@lfcnassif lfcnassif left a comment

Choose a reason for hiding this comment

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

Thanks @wladimirleite!

@lfcnassif lfcnassif merged commit 474f4b9 into master Oct 15, 2024
2 checks passed
@lfcnassif lfcnassif deleted the #2337_FixWAMessageCompare branch October 15, 2024 18:45
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.

Error parsing WhatsApp DB (Comparison method violates its general contract)
2 participants