生产环境出现的错误排查,错误log如下

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]

 整个问题在生产环境上间断性出现,在本地开发环境是好的,上网搜了下这个错误,发现遇到的人还不少。具体的原因是因为jdk7的timesort新排序算法导致,具体可以参考这篇博文:

http://www.lifebackup.cn/timsort-java7.html

总结如下:比较器的比较逻辑必须正确,且需要放回相等的情况,即0;同时需要注意的是对于引用类型的比较需要转化成简单类型进行比较

Comparison method violates its general contract的更多相关文章

  1. java-collections.sort异常Comparison method violates its general contract!

    转载:http://www.tuicool.com/articles/MZreyuv 异常信息 java.lang.IllegalArgumentException: Comparison metho ...

  2. JDK7的Comparison method violates its general contract异常

    1.摘要 前一阵遇到了一个使用Collections.sort()时报异常的问题,跟小伙伴@zhuidawugui 一起排查了一下,发现问题的原因是JDK7的排序实现改为了TimSort,之后我们又进 ...

  3. 解决“Comparison method violates its general contract!”

    The ONE跑MaxProp.Prophet可能(取决于你JDK的版本)会报“java.lang.IllegalArgumentException: Comparison method violat ...

  4. 排序遇到问题 JDK7的Comparison method violates its general contract

    图解JDK7的Comparison method violates its general contract异常 楼主分析的很详细,能力有限,我看得迷迷糊糊的,不过大致知道这个错误的起因了.学习了,谢 ...

  5. Comparison method violates its general contract 解决

    java.lang.IllegalArgumentException: Comparison method violates its general contract! 原因 JDK7中的Collec ...

  6. 解决 Comparison method violates its general contract!

    问题:Comparison method violates its general contract!报错 Collections.sort(list, new Comparator<Integ ...

  7. 关于jdk7中 使用Collections的排序方法时报Comparison method violates its general contract!异常

    参考: Comparison method violates its general contract Comparison method violates its general contract! ...

  8. [ Error 分析] Comparison method violates its general contract!

    public static void main(String[] args) { List<Long> ret = new ArrayList<>(); int n = 103 ...

  9. Comparison method violates its general contract! 异常原因

    项目运行期间出现Comparison method violates its general contract!异常,网上查阅了一下,原因还是比较明确的: Collections.sort(list, ...

随机推荐

  1. WebRTC源码分析:音频模块结构分析

    一.概要介绍WebRTC的音频处理流程,见下图: webRTC将音频会话抽象为一个通道Channel,譬如A与B进行音频通话,则A需要建立一个Channel与B进行音频数据传输.上图中有三个Chann ...

  2. beantool.map2Bean(map,obj)

  3. POJ2155Matrix(二维线段树)

    链接http://poj.org/problem?id=2155 题目操作就是说,每次操作可以是编辑某个矩形区域,这个区域的0改为1,1改为0,每次查询只查询某一个点的值是0还是1. 方法:二维线段树 ...

  4. C++中使用接口

    面向对象的语言诸如JAVA提供了Interface来实现接口,但C++却没有这样一个东西,尽管C++ 通过纯虚基类实现接口,譬如COM的C++实现就是通过纯虚基类实现的(当然MFC的COM实现用了嵌套 ...

  5. android ExpandAbleListView控件

    ExpandAbleListView控件 1.API对ExpandAbleListView的解释:

  6. Mes首检确认统计的存储过程

    USE [ChiefmesNEW]GO/****** Object: StoredProcedure [dbo].[st_MES_RptInspectFirstCollect] Script Date ...

  7. 【JUnit】EasyMock用法总结

    使用EasyMock的总体步骤 1.生成Mock接口 IService mockService = EasyMock.createMock("name", IService.cla ...

  8. JobScheduler

    任务写在JobService中 public class TestJobService extends JobService { private static final String TAG = & ...

  9. CorelDraw x6【Cdr x6】官方简体中文破解版(64位)安装图文教程、破解注册方法

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  10. CMSIS Example - osMutex osMutexWait osMutexRelease

    osMutexDef( Mutex ); osMutexId mutex; void Thread0( void * arg); void Thread1( void * arg); osThread ...