slievrly commented on code in PR #7282:
URL: https://github.com/apache/incubator-seata/pull/7282#discussion_r2055140962


##########
common/src/main/java/org/apache/seata/common/util/NetUtil.java:
##########
@@ -138,18 +138,20 @@ public static String[] splitIPPortStr(String address) {
         if (address.charAt(0) == '[') {
             address = removeBrackets(address);
         }
-        String[] serverAddArr = null;
         int i = address.lastIndexOf(Constants.IP_PORT_SPLIT_CHAR);
         if (i > -1) {
-            serverAddArr = new String[2];
-            String hostAddress = address.substring(0,i);
+            String hostAddress = address.substring(0, i);
             if (hostAddress.contains("%")) {
                 hostAddress = hostAddress.substring(0, 
hostAddress.indexOf("%"));
             }
-            serverAddArr[0] = hostAddress;
-            serverAddArr[1] = address.substring(i + 1);
+            String portStr = address.substring(i + 1);
+            if (StringUtils.isBlank(hostAddress) || 
StringUtils.isBlank(portStr)) {
+                throw new IllegalArgumentException("Invalid endpoint format: " 
+ address + ". Endpoint should be in the format ip:port.");

Review Comment:
   Pls. add UT case for this exception.



-- 
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...@seata.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to