Comparison method violates its general contract! 与 自定义比较器
Comparisonmethodviolatesitsgeneralcontract!压测时发现的报错,原因是自定义的比较器没有满足可逆比较。Comparator接口的compare方法文档中有标注:Theimplementormustensurethatsgn(compare(x,y))==-sgn(compare(y,x))forallxandy.下面用单元测试还原一下报错场景:publics