Github user anmolnar commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/648#discussion_r221368841 --- Diff: src/java/main/org/apache/zookeeper/ClientCnxn.java --- @@ -990,6 +992,27 @@ private void sendPing() { private boolean saslLoginFailed = false; private void startConnect(InetSocketAddress addr) throws IOException { + boolean canonicalize = true; + try { + canonicalize = Boolean.parseBoolean(System.getProperty(ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME, "true")); + } catch (IllegalArgumentException ea) { + //ignored ... + } + + if (canonicalize) { + try { + InetAddress ia = addr.getAddress(); + LOG.warn("ia {}", ia); + if (ia == null) { + ia = InetAddress.getByName(addr.getHostName()); + } + String host = (ia != null) ? ia.getCanonicalHostName() : addr.getHostName(); + addr = new InetSocketAddress(InetAddress.getByAddress(host, ia.getAddress()), addr.getPort()); --- End diff -- I'm thinking of how much value does it have to replace the address with the canonicalized version for the entire client. We might want to implement this strictly and only for `ZooKeeperSaslClient`. I'd rather move this logic to the creation of `ZooKeeperSaslClient`. Something like: ```java zooKeeperSaslClient = new ZooKeeperSaslClient(principalUserName + "/" + canonicalize ? addr.getAddress().getCanonicalHostName() : addr.getHostName()); ```
---