arcao / Geocaching4Locus

A Locus simple add-on allows you to download and import caches directly from Geocaching.com si­te.
http://geocaching4locus.eu/
GNU General Public License v3.0
20 stars 8 forks source link

Sorting for geocache logs is badly written #101

Closed arcao closed 6 years ago

arcao commented 6 years ago

The comparison method for sorting geocache logs is badly written. TimSort implementation in Android SDK can verify wheres x.compareTo(y) == 0 == y.compareTo(x). If this is not met, it throws IllegalArgumentException:

Non-fatal Exception: 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.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:2010)
       at java.util.Collections.sort(Collections.java:1883)
       at locus.api.mapper.GeocacheLogConverter.sortLocusGeocachingLogsByDate(SourceFile:5124)
       at com.arcao.geocaching4locus.update.task.UpdateTask.locus.api.mapper.DataMapper.addCacheLogs(SourceFile:3050)
       at com.arcao.geocaching4locus.update.task.UpdateTask.doInBackground(SourceFile:42)
arcao commented 6 years ago

Fixed.