Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Resource Resolver 1.0.6
-
None
Description
On Java7 sorting the map entries might result in an IllegalStateException:
java.lang.IllegalArgumentException: Comparison method violates its general
contract!
at java.util.ComparableTimSort.mergeLo(ComparableTimSort.java:714)
at java.util.ComparableTimSort.mergeAt(ComparableTimSort.java:451)
at java.util.ComparableTimSort.mergeCollapse(ComparableTimSort.java:376)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:182)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:146)
at java.util.Arrays.sort(Arrays.java:472)
at java.util.Collections.sort(Collections.java:155)
The behaviour of sorting has changed with Java7 (see http://stackoverflow.com/questions/7849539/comparison-method-violates-its-general-contract-java-7-only) and it now throws such an exception if the compare method is not implemented in an consistent way.
In our case: if the two strings have the same lengths, always 1 is returned, so compareTo("a", "b") returns 1 while compareTo("b", "a") returns 1 as well