li4wang commented on code in PR #2321:
URL: https://github.com/apache/zookeeper/pull/2321#discussion_r2636938227


##########
zookeeper-server/src/main/java/org/apache/zookeeper/client/ConnectStringParser.java:
##########
@@ -49,27 +50,71 @@ public final class ConnectStringParser {
      * @throws IllegalArgumentException
      *             for an invalid chroot path.
      */
-    public ConnectStringParser(String connectString) {
-        // parse out chroot, if any
-        int off = connectString.indexOf('/');
-        if (off >= 0) {
-            String chrootPath = connectString.substring(off);
-            // ignore "/" chroot spec, same as null
-            if (chrootPath.length() == 1) {
-                this.chrootPath = null;
-            } else {
-                PathUtils.validatePath(chrootPath);
-                this.chrootPath = chrootPath;
-            }
-            connectString = connectString.substring(0, off);
+    public ConnectStringParser(final String connectString) {
+        if (StringUtils.isBlank(connectString)) {
+            throw new IllegalArgumentException("Connect string cannot be null 
or empty");
+        }
+
+        if (connectString.startsWith(DNS_SRV_PREFIX)) {
+            parseDnsSrvFormat(connectString);
         } else {
-            this.chrootPath = null;
+            parseHostPortFormat(connectString);
         }
+    }
 
-        List<String> hostsList = split(connectString, ",");
+    public String getChrootPath() {
+        return chrootPath;
+    }
+
+    public ArrayList<InetSocketAddress> getServerAddresses() {
+        return serverAddresses;
+    }
+
+
+    /**
+     * Gets the connection type for the given connect string.
+     *
+     * @param connectString the connection string to analyze
+     * @return ConnectionType.DNS_SRV if it's a DNS SRV connect string, 
ConnectionType.HOST_PORT otherwise
+     */
+    public static ConnectionType getConnectionType(final String connectString) 
{

Review Comment:
   Updated in the https://github.com/apache/zookeeper/pull/2320



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to