fastjson 报错 Comparison method violates its general contract!

fastjson 报错 Comparison method violates its general contract!_第1张图片

这一行报错

java.lang.IllegalArgumentException: Comparison method violates its general contract!
    at java.util.ComparableTimSort.mergeHi(ComparableTimSort.java:866)
    at java.util.ComparableTimSort.mergeAt(ComparableTimSort.java:483)
    at java.util.ComparableTimSort.mergeForceCollapse(ComparableTimSort.java:422)
    at java.util.ComparableTimSort.sort(ComparableTimSort.java:222)
    at java.util.Arrays.sort(Arrays.java:1312)
    at java.util.Arrays.sort(Arrays.java:1506)
    at java.util.ArrayList.sort(ArrayList.java:1462)
    at java.util.Collections.sort(Collections.java:141)
    at com.alibaba.fastjson2.writer.ObjectWriterCreatorASM.createObjectWriter(ObjectWriterCreatorASM.java:344)
    at com.alibaba.fastjson2.writer.ObjectWriterProvider.getObjectWriter(ObjectWriterProvider.java:195)
    at com.alibaba.fastjson2.JSONWriter.getObjectWriter(JSONWriter.java:460)
    at com.alibaba.fastjson2.writer.FieldWriterList.getItemWriter(FieldWriterList.java:79)
    at com.alibaba.fastjson2.writer.FieldWriterList.writeList(FieldWriterList.java:191)
    at com.alibaba.fastjson2.writer.ObjectWriter_2.write(Unknown Source)
    at com.alibaba.fastjson2.JSON.toJSONString(JSON.java:2183)
    at com.ruoyi.web.controller.publicsearch.EpTransUpdataController.createObjectData(EpTransUpdataController.java:1148)

原因fastjson中用到了Arrays.sort方法,导致排序错误

解决办法将fastjson 的版本从2.0.16 升级到 2.0.24

 

你可能感兴趣的:(java,jvm,开发语言)