From 39a6cb6e887d43cbb26d0eaf9564772e50a59a62 Mon Sep 17 00:00:00 2001 From: Tiewei Fang <43782773+BePPPower@users.noreply.github.com> Date: Wed, 31 Jan 2024 20:52:18 +0800 Subject: [PATCH] [fix](JDK17) The objects stored in `PriorityQueue` must implement the `Comparable` interface (#30050) (#30625) Issue Number: #30484 The objects stored in PriorityQueue must implement the Comparable interface or passed into the customized `Comparator`. If we don't do this, run the program in the JDK17 environment will report an exception: ```java Caused by: java.lang.AssertionError: Expect exception msg contains 'query wait timeout', but meet 'java.sql.SQLException: ClassCastException, msg: class org.apache.doris.resource.workloadgroup.QueueToken cannot be cast to class java.lang.Comparable (org.apache.doris.resource.workloadgroup.QueueToken is in unnamed module of loader 'app'; java.lang.Comparable is in module java.base of loader 'bootstrap')' ``` --- .../doris/resource/workloadgroup/QueueToken.java | 10 +++++++++- .../test_array_zip_array_enumerate_uniq.groovy | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/QueueToken.java b/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/QueueToken.java index 17299d3ea3b27e4..189ba77e8de0686 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/QueueToken.java +++ b/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/QueueToken.java @@ -28,9 +28,14 @@ // used to mark QueryQueue offer result // if offer failed, then need to cancel query // and return failed reason to user client -public class QueueToken { +public class QueueToken implements Comparable { private static final Logger LOG = LogManager.getLogger(QueueToken.class); + @Override + public int compareTo(QueueToken other) { + return Long.compare(this.tokenId, other.getTokenId()); + } + enum TokenState { ENQUEUE_SUCCESS, READY_TO_RUN @@ -136,4 +141,7 @@ public boolean equals(Object obj) { return tokenId == other.tokenId; } + public long getTokenId() { + return tokenId; + } } diff --git a/regression-test/suites/datatype_p0/nested_types/query/array_functions/test_array_zip_array_enumerate_uniq.groovy b/regression-test/suites/datatype_p0/nested_types/query/array_functions/test_array_zip_array_enumerate_uniq.groovy index b8207c1ee76ab3d..38772921ecea23a 100644 --- a/regression-test/suites/datatype_p0/nested_types/query/array_functions/test_array_zip_array_enumerate_uniq.groovy +++ b/regression-test/suites/datatype_p0/nested_types/query/array_functions/test_array_zip_array_enumerate_uniq.groovy @@ -25,7 +25,7 @@ suite("test_array_zip_array_enumerate_uniq", "p0") { SELECT array_zip(); """ } catch (Exception ex) { - assertTrue(ex.getMessage().contains("errCode = 2, detailMessage = Unexpected exception: 0")) + assertTrue(ex.getMessage().contains("errCode = 2, detailMessage = Unexpected exception: ")) } try {