From 8eed95f4eafb72d4a79d806ba3446f97e7113287 Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 9 Feb 2022 11:28:31 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-66342=20=E7=BB=84=E4=BB=B6=E5=A4=8D?= =?UTF-8?q?=E7=94=A8-=E8=AE=BE=E8=AE=A1=E5=99=A8=E9=87=8C=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=BB=84=E4=BB=B6=E9=A1=B5=E9=9D=A2=E4=B8=80=E7=9B=B4?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8A=A0=E8=BD=BD=E4=B8=AD=EF=BC=8C=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=B2=A1=E6=9C=89=E6=8A=A5=E9=94=99=EF=BC=9B=E5=B8=86?= =?UTF-8?q?=E8=BD=AF=E5=B8=82=E5=9C=BAweb=E9=A1=B5=E9=9D=A2=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 Comparator中比较double时使用了允许误差的比较方法,产生异常 【改动思路】 使用Double.compare方法比较double值 --- .../design/mainframe/share/sort/OnlineWidgetSortType.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/sort/OnlineWidgetSortType.java b/designer-form/src/main/java/com/fr/design/mainframe/share/sort/OnlineWidgetSortType.java index 437835662a..3a51357747 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/sort/OnlineWidgetSortType.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/sort/OnlineWidgetSortType.java @@ -27,7 +27,11 @@ public enum OnlineWidgetSortType implements SortType { public int compare(OnlineShareWidget o1, OnlineShareWidget o2) { double t1 = getSortValue(o1, parameterMap); double t2 = getSortValue(o2, parameterMap); - return ComparatorUtils.compareCommonType(t2, t1); + // Comparator中比较double/float相等时,不允许误差. 否则会违背 "若x = y , y = z, 则x = z"的约定。 + // 因为允许误差的情况下,x和y间的误差在允许范围内,被判定相等,y和间的误差在允许范围内,被判定相等, + // 但x和z间的误差可能超出允许范围,从而不相等,因此会违背上述约定。 + // 产生IllegalArgumentException: Comparison method violates its general contract! + return Double.compare(t2, t1); } }); }