stoty commented on code in PR #6456:
URL: https://github.com/apache/hbase/pull/6456#discussion_r2321340597


##########
hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java:
##########
@@ -356,13 +359,14 @@ public static ServerName parseServerName(final String 
str) {
    * Checks if the provided server address is formatted as an IPv6 address. 
This method uses Java's
    * InetAddress to parse the input and confirms if the address is an instance 
of Inet6Address for
    * robust validation instead of relying on string splitting.
-   * @param serverAddress The address string to validate (can be a hostname or 
IP)
+   * @param serverAddress The address string to validate
    * @return true if the address is a valid IPv6 address; false otherwise.
    */
   public static boolean isIpv6ServerName(String serverAddress) {
     try {
       InetAddress address = InetAddress.getByName(serverAddress);
-      return address instanceof Inet6Address;
+      return address instanceof Inet6Address && 
!address.getHostName().equals(serverAddress)

Review Comment:
   We use this check to decide whether we need to replace the colons, which 
needs to be done whether the address is canonical or not.
   
   The current logic also does not match the method name.
   
   I have not checked every possible call location, so it is possible that this 
method never gets called when address.getHostName().equals(serverAddress) is 
true, but it'S still fragile.
   
   What do we gain by adding that extra clause ?



-- 
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]

Reply via email to