From 204fa45a48dfd55dd8a2696e9c1e9dcc7125baeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=BB=BA=E5=8D=8E?= Date: Tue, 16 Feb 2021 22:34:27 +0800 Subject: [PATCH] [FE][Bug] Fix overflow in RuntimeProfile.sortChildren. (#5377) If the difference between the two times exceeds Integer.MAX_VALUE, the compare's return value will overflow and the flow exception may be triggered when sorting profile. --- .../java/org/apache/doris/common/util/RuntimeProfile.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java index 0eb78d5ad7..83e8d2b27c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java @@ -369,9 +369,8 @@ public class RuntimeProfile { @Override public int compare(Pair profile1, Pair profile2) { - long distance = profile2.first.getCounterTotalTime().getValue() - - profile1.first.getCounterTotalTime().getValue(); - return (int) distance; + return Long.valueOf(profile2.first.getCounterTotalTime().getValue()) + .compareTo(profile1.first.getCounterTotalTime().getValue()); } }); }