Carsten Ziegeler created SLING-2975:
---------------------------------------

             Summary: MapEntry#compareTo method is not consistent and might 
throw ISE on Java7
                 Key: SLING-2975
                 URL: https://issues.apache.org/jira/browse/SLING-2975
             Project: Sling
          Issue Type: Bug
          Components: ResourceResolver
    Affects Versions: Resource Resolver 1.0.6
            Reporter: Carsten Ziegeler
            Assignee: Carsten Ziegeler
             Fix For: Resource Resolver 1.1.0


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


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to