Github user eolivelli commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/587#discussion_r223347154
--- Diff:
zookeeper-client/zookeeper-client-java/src/main/java/org/apache/zookeeper/client/ConnectStringParser.java
---
@@ -68,14 +71,16 @@ public ConnectStringParser(String connectString) {
List<String> hostsList = split(connectString,",");
for (String host : hostsList) {
int port = DEFAULT_PORT;
- int pidx = host.lastIndexOf(':');
- if (pidx >= 0) {
- // otherwise : is at the end of the string, ignore
- if (pidx < host.length() - 1) {
- port = Integer.parseInt(host.substring(pidx + 1));
+ try {
+ String[] hostAndPort = ConfigUtils.getHostAndPort(host);
+ host = hostAndPort[0];
+ if (hostAndPort.length == 2) {
+ port = Integer.parseInt(hostAndPort[1]);
}
- host = host.substring(0, pidx);
+ } catch (ConfigException e) {
+ e.printStackTrace();
--- End diff --
cc @maoling
---