Check for errors in the production environment. The error log is as follows:
java.lang.IllegalArgumentException: Comparison method violates its general contract!at java.util.TimSort.mergeLo(TimSort.java:747) ~[na:1.7.0_40]at java.util.TimSort.mergeAt(TimSort.java:483) ~[na:1.7.0_40]at java.util.TimSort.mergeCollapse(TimSort.java:408) ~[na:1.7.0_40]at java.util.TimSort.sort(TimSort.java:214) ~[na:1.7.0_40]at java.util.TimSort.sort(TimSort.java:173) ~[na:1.7.0_40]at java.util.Arrays.sort(Arrays.java:659) ~[na:1.7.0_40]at java.util.Collections.sort(Collections.java:217) ~[na:1.7.0_40]
The problem occurs intermittently in the production environment. It is good in the local development environment. I searched the internet for this error and found that there were still many people. The specific cause is the new timesort Sorting Algorithm of JDK 7. For details, refer to this blog post:
Http://www.lifebackup.cn/timsort-java7.html
Summary: The comparison logic of the comparator must be correct and equal conditions must be put back, that is, 0. Note that the comparison of the reference type needs to be converted to a simple type for comparison.
Comparison Method violates its general contract