C0urante commented on code in PR #14089: URL: https://github.com/apache/kafka/pull/14089#discussion_r1275115110
########## connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginDesc.java: ########## @@ -110,11 +110,18 @@ public int hashCode() { } @Override - public int compareTo(PluginDesc<T> other) { + public int compareTo(PluginDesc<?> other) { int nameComp = name.compareTo(other.name); int versionComp = encodedVersion.compareTo(other.encodedVersion); // isolated plugins appear after classpath plugins when they have identical versions. int isolatedComp = Boolean.compare(other.loader instanceof PluginClassLoader, loader instanceof PluginClassLoader); - return nameComp != 0 ? nameComp : (versionComp != 0 ? versionComp : isolatedComp); + // choose an arbitrary order between different locations and types + int loaderComp = location.compareTo(other.location); Review Comment: We should probably make all of the comparisons here null-safe, or enforce that the relevant fields are non-null in the constructor. ########## connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginDesc.java: ########## @@ -110,11 +110,18 @@ public int hashCode() { } @Override - public int compareTo(PluginDesc<T> other) { + public int compareTo(PluginDesc<?> other) { int nameComp = name.compareTo(other.name); int versionComp = encodedVersion.compareTo(other.encodedVersion); // isolated plugins appear after classpath plugins when they have identical versions. int isolatedComp = Boolean.compare(other.loader instanceof PluginClassLoader, loader instanceof PluginClassLoader); - return nameComp != 0 ? nameComp : (versionComp != 0 ? versionComp : isolatedComp); + // choose an arbitrary order between different locations and types + int loaderComp = location.compareTo(other.location); Review Comment: This is causing an NPE during unit tests (see CI results): ```suggestion int loaderComp = Objects.compare(location, other.location, String::compareTo); ``` -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org