lhotari opened a new pull request, #24772: URL: https://github.com/apache/pulsar/pull/24772
Fixes #24754 ### Motivation - JVM's default sorting algorithm "TimSort" will fail with exception if `compareTo` doesn't meet [the contract of `Comparable.compareTo` interface](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Comparable.html#compareTo(T)) The contract of `Comparable.compareTo`: * The implementor must ensure [signum](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html#signum(int))(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.) * The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0. * Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z. ### Modifications - address the compareTo violation by using "resolution" instead of "difference" when comparing values since it's not possible to fulfill the [`Comparable.compareTo` contract](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Comparable.html#compareTo(T)) by using a difference. ### Documentation <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc` <!-- Your PR contains doc changes. --> - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later --> - [x] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-complete` <!-- Docs have been already added --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
