brianloss commented on a change in pull request #2551:
URL: https://github.com/apache/accumulo/pull/2551#discussion_r822036320



##########
File path: core/src/main/java/org/apache/accumulo/core/util/HostAndPort.java
##########
@@ -281,4 +282,13 @@ public int getPortOrDefault(int defaultPort) {
     return hasPort() ? port : defaultPort;
   }
 
+  /**
+   * HostAndPort must implement compareTo. As this is a seldom used utiltiy, 
compareTo simply treats
+   * HostAndPort values as Strings.
+   */
+  @Override
+  public int compareTo(HostAndPort other) {
+    return 
Comparator.nullsFirst(Comparator.comparing(HostAndPort::toString)).compare(this,
 other);

Review comment:
       The case I'm thinking of is where a host, say localhost, has ports 9999 
and 10000. The 10000 will sort first if you use a string comparison from 
toString, and second if you were actually comparing the integer port values.




-- 
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: notifications-unsubscr...@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to