From dev-return-72037-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Thu Aug 2 05:09:08 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 83FB7180634 for ; Thu, 2 Aug 2018 05:09:08 +0200 (CEST) Received: (qmail 13487 invoked by uid 500); 2 Aug 2018 03:09:07 -0000 Mailing-List: contact dev-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list dev@zookeeper.apache.org Received: (qmail 12899 invoked by uid 99); 2 Aug 2018 03:09:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Aug 2018 03:09:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E9392DFAB3; Thu, 2 Aug 2018 03:09:05 +0000 (UTC) From: maoling To: dev@zookeeper.apache.org Reply-To: dev@zookeeper.apache.org References: In-Reply-To: Subject: [GitHub] zookeeper pull request #587: ZOOKEEPER-3106: Zookeeper client supports IPv6 ... Content-Type: text/plain Message-Id: <20180802030905.E9392DFAB3@git1-us-west.apache.org> Date: Thu, 2 Aug 2018 03:09:05 +0000 (UTC) Github user maoling commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/587#discussion_r207090394 --- Diff: src/java/main/org/apache/zookeeper/client/ConnectStringParser.java --- @@ -68,14 +69,26 @@ public ConnectStringParser(String connectString) { List 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)); - } - host = host.substring(0, pidx); + if (!connectString.startsWith("[")) {//IPv4 + 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)); + } + host = host.substring(0, pidx); + } + } else { //IPv6 --- End diff -- @enixon thanks for your review.after collecting enough suggestions,I will polish up this issue. ---