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

User reported crash #216

Closed
remulasce opened this issue Apr 24, 2015 · 3 comments
Closed

User reported crash #216

remulasce opened this issue Apr 24, 2015 · 3 comments
Assignees
Labels
Milestone

Comments

@remulasce
Copy link
Owner

Looks like I goofed in a priority comparison method.

Offending comparison:
public int compare(Trip lhs, Trip rhs) {
return (lhs.getPriority() < rhs.getPriority()) ? 1 : -1;
}

Violates the contract of comparitors, because if the priorities are equal, -1 will be returned, which denotes that one side is greater.

This is obviously incorrect.

Also, it's a simple fix.

User reports this happened with screen off when notification sounded. I think it was when he turned on his phone, all the priorities got recalculated and reordered, revealing this issue.

It was likely for priorities to be exactly equal because each trip in a stop has identical priority.

USER_COMMENT=alarm sounded when the screen was off
ANDROID_VERSION=4.4.2
APP_VERSION_NAME=0.71
BRAND=MetroPCS
PHONE_MODEL=LGMS323
CUSTOM_DATA=
STACK_TRACE=java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:864)
at java.util.TimSort.mergeAt(TimSort.java:481)
at java.util.TimSort.mergeForceCollapse(TimSort.java:422)
at java.util.TimSort.sort(TimSort.java:219)
at java.util.TimSort.sort(TimSort.java:169)
at java.util.Arrays.sort(Arrays.java:2023)
at java.util.Collections.sort(Collections.java:1883)
at com.remulasce.lametroapp.c.b.a(ServiceRequestHandler.java:39)
at com.remulasce.lametroapp.c.b.a(ServiceRequestHandler.java:51)
at com.remulasce.lametroapp.p.a(TripPopulator.java:226)
at com.remulasce.lametroapp.p.run(TripPopulator.java:195)
at java.lang.Thread.run(Thread.java:841)

@remulasce remulasce added the bug label Apr 24, 2015
@remulasce remulasce self-assigned this Apr 24, 2015
@remulasce remulasce added this to the User Feedback milestone Apr 24, 2015
@remulasce
Copy link
Owner Author

I have a similar priority comparison elsewhere, but I remember I specifically did it correctly there.

I did do a ctrl-f across the project. There's ~4 other comparisons similar to this one, none of them are broken.

@nighelles
Copy link
Collaborator

The java_core uses a comparison based on getDistanceToStop which is never
actually declared

On Thursday, April 23, 2015, remulasce notifications@github.com wrote:

I have a similar priority comparison elsewhere, but I remember I
specifically did it correctly there.

I did do a ctrl-f across the project. There's ~4 other comparisons similar
to this one, none of them are broken.


Reply to this email directly or view it on GitHub
#216 (comment).

@remulasce
Copy link
Owner Author

Then make an issue about it.
This issue has been fixed. Beta apk is on Play Store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants