Apache9 commented on code in PR #5642:
URL: https://github.com/apache/hbase/pull/5642#discussion_r1461887062


##########
hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java:
##########
@@ -143,11 +143,10 @@ public static ServerName valueOf(final String hostname, 
final int port, final lo
    * instances, though we may return a shared immutable object as an internal 
optimization.
    */
   public static ServerName valueOf(final String serverName) {
-    int firstSep = serverName.indexOf(SERVERNAME_SEPARATOR);
-    int lastSep = serverName.lastIndexOf(SERVERNAME_SEPARATOR);
-    String hostname = serverName.substring(0, firstSep);
-    int port = Integer.parseInt(serverName.substring(firstSep + 1, lastSep));
-    long startCode = Long.parseLong(serverName.substring(lastSep + 1));
+    String[] splits = serverName.split(",");

Review Comment:
   Checked the code change in HBASE-24305, seems the problem is that, before 
HBASE-24305, if we pass a String with only host and port, it will use port as 
start code to create the server name, which is obviously incorret but it could 
work if you just do not care about the start code...
   
   So I suggest that, we introduce a new method, explicitly say that we can 
pass ServerName without start code, and then you can use it if you do not care 
about start code.
   
   WDYT?



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