todotxt / todo.txt-android

Official Todo.txt Android app for managing your todo.txt file stored in Dropbox.
http://todotxt.com
GNU General Public License v3.0
1.24k stars 406 forks source link

Resolve RuntimeException #438

Closed ginatrapani closed 10 years ago

ginatrapani commented 11 years ago

As reported in the Play developer console:

java.lang.RuntimeException: Unable to resume activity {com.todotxt.todotxttouch/com.todotxt.todotxttouch.TodoTxtTouch}: java.lang.IllegalArgumentException: Comparison method violates its general contract!
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2639)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2667)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2140)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4950)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeLo(TimSort.java:743)
at java.util.TimSort.mergeAt(TimSort.java:479)
at java.util.TimSort.mergeCollapse(TimSort.java:406)
at java.util.TimSort.sort(TimSort.java:210)
at java.util.TimSort.sort(TimSort.java:169)
at java.util.Arrays.sort(Arrays.java:2038)
at java.util.Collections.sort(Collections.java:1891)
at com.todotxt.todotxttouch.task.TaskBagImpl.getTasks(TaskBagImpl.java:156)
at com.todotxt.todotxttouch.TodoTxtTouch.setFilteredTasks(TodoTxtTouch.java:1332)
at com.todotxt.todotxttouch.TodoTxtTouch.onResume(TodoTxtTouch.java:436)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1199)
at android.app.Activity.performResume(Activity.java:5253)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2629)
... 12 more
jaydm commented 11 years ago

This exception has to do with the comparitors not being able to return the full set of (-1, 0, 1) for any pair of tasks.

I've looked them over and as far as I can tell - they should be able to.

How many occurances of that exception were reported? There must be a fairly exotic set of data that they have to be able to cause it.

Also, the exception does not give enough information to be able to tell which sort order is the problem.

jaydm commented 10 years ago

After looking at the sort class again, I did find issues with a couple of the comparators.

With the extended sort test, the existing text ascending test failed using the original task and sort classes.

And, both of the new date sort tests failed as well.

jaydm commented 10 years ago

My recent pull request should resolve this issue.

Has anyone had a chance to take a look at it?

jaydm commented 10 years ago

This should be fixed with the merge of jaydm/sorting-438-442.

If it recurs, then it should probably be opened as a new issue.