alibaba/nacos · warning · IllegalArgumentException
ip and port string cannot be empty!
Error message
ip and port string cannot be empty!
What it means
Thrown by InternetAddressUtil.splitIpPortStr(String) when the input address string is blank. The splitter is the foundation for parsing server addresses (host:port) supporting IPv4 and IPv6, and a blank input is treated as an illegal argument rather than an empty result.
Source
Thrown at common/src/main/java/com/alibaba/nacos/common/utils/InternetAddressUtil.java:137
* Check if the address contains a port. 2020/9/3 14:53
*
* @param address address string
* @return boolean
*/
public static boolean containsPort(String address) {
return splitIpPortStr(address).length == SPLIT_IP_PORT_RESULT_LENGTH;
}
/**
* Split IP and port strings, support IPv4 and IPv6, IP in IPv6 must be enclosed with []. Illegal IP will get
* abnormal results.
*
* @param str ip and port string
* @return java.lang.String[]
*/
public static String[] splitIpPortStr(String str) {
if (StringUtils.isBlank(str)) {
throw new IllegalArgumentException("ip and port string cannot be empty!");
}
String[] serverAddrArr;
if (str.startsWith(IPV6_START_MARK) && StringUtils.containsIgnoreCase(str, IPV6_END_MARK)) {
if (str.endsWith(IPV6_END_MARK)) {
serverAddrArr = new String[1];
serverAddrArr[0] = str;
} else {
serverAddrArr = new String[2];
serverAddrArr[0] = str.substring(0, (str.indexOf(IPV6_END_MARK) + 1));
serverAddrArr[1] = str.substring((str.indexOf(IPV6_END_MARK) + 2));
}
} else {
serverAddrArr = str.split(IP_PORT_SPLITER);
}
return serverAddrArr;
}
/**View on GitHub (pinned to 9b989acdf1)
Solutions
- Sanitize the address list: split on the list delimiter, trim, and filter blanks before parsing each entry.
- Validate the serverAddr / member-list config value at startup.
- Reject empty tokens explicitly with a clearer error before reaching splitIpPortStr.
Example fix
// before
for (String addr : serverList.split(",")) {
String[] parts = InternetAddressUtil.splitIpPortStr(addr);
}
// after
for (String addr : serverList.split(",")) {
String trimmed = addr.trim();
if (trimmed.isEmpty()) continue;
String[] parts = InternetAddressUtil.splitIpPortStr(trimmed);
} Defensive patterns
Strategy: validation
Validate before calling
for (String addr : serverList.split(",")) {
String trimmed = addr.trim();
if (trimmed.isEmpty()) continue; // skip blank entries
String[] parts = InternetAddressUtil.splitIpPortStr(trimmed);
} Prevention
- Trim and drop blank tokens from comma-separated address lists before parsing.
- Validate server-addr / member-list config at startup.
When it happens
Trigger: Parsing a server address list where one entry is empty — e.g., 'a.com:8848,,b.com:8848' splits into a blank token; or the entire address property is unset/blank.
Common situations: Malformed server-addr configuration (trailing comma, double comma); a cluster member list with an empty entry; reading an address from a config/environment variable that was not set.
Related errors
- {} is invalid IP
- [http-client] invalid connect timeout:{}
- Illegal url path expression
- Invalid boolean value '{}'
- Cannot convert String [{}] to Integer
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/85f9d850cd2afe35.
Report an issue: GitHub.