IpUtils { public static List<HostPort> parseAsHostPorts(String addressDesc){ if(addressDesc == null){ throw new IllegalArgumentException("addressDesc null"); } if(StringUtil.isEmpty(addressDesc)){ return new LinkedList<>(); } List<HostPort> result = new LinkedList<>(); String []addresses = addressDesc.split("\\s*,\\s*"); for(String address : addresses){ try { HostPort hostPort = parseSingleAsHostPort(address); result.add(hostPort); } catch (Exception e) { logger.warn("[parse][wrong address]" + address); } } return result; }  static String getIp(SocketAddress socketAddress); static boolean isValidIpFormat(String ip); static boolean isPort(String str); static InetAddress getFistNonLocalIpv4ServerAddress(); static InetAddress getFistNonLocalIpv4ServerAddress(String ipPrefixPrefer); static boolean isLocal(String host); static List<HostPort> parseAsHostPorts(String addressDesc); static List<InetSocketAddress> parse(String addressDesc); static InetSocketAddress parseSingle(String singleAddress); static Pair<String, Integer> parseSingleAsPair(String singleAddress); static String[] splitIpAddr(String ip);  }
@Test public void testParseAsHostPorts(){ Assert.assertEquals(new LinkedList<>(), IpUtils.parseAsHostPorts("")); }