Skip to content

Commit

Permalink
[fix](JDK17) The objects stored in PriorityQueue must implement the…
Browse files Browse the repository at this point in the history
… `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')'
```
  • Loading branch information
BePPPower authored and Doris-Extras committed Jan 31, 2024
1 parent 192c3ce commit 39a6cb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<QueueToken> {
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
Expand Down Expand Up @@ -136,4 +141,7 @@ public boolean equals(Object obj) {
return tokenId == other.tokenId;
}

public long getTokenId() {
return tokenId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 39a6cb6

Please sign in to comment.