zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fpj <...@git.apache.org>
Subject [GitHub] zookeeper pull request #150: ZOOKEEPER-2184: Zookeeper Client should re-reso...
Date Mon, 23 Jan 2017 22:51:47 GMT
Github user fpj commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/150#discussion_r97436195
  
    --- Diff: src/java/main/org/apache/zookeeper/client/StaticHostProvider.java ---
    @@ -57,26 +62,20 @@
         public StaticHostProvider(Collection<InetSocketAddress> serverAddresses)
                 throws UnknownHostException {
             for (InetSocketAddress address : serverAddresses) {
    -            InetAddress ia = address.getAddress();
    -            InetAddress resolvedAddresses[] = InetAddress.getAllByName((ia!=null) ? ia.getHostAddress():
    -                address.getHostName());
    +            InetAddress resolvedAddresses[];
    +            try {
    +                Method m = InetSocketAddress.class.getDeclaredMethod("getHostString");
    +                m.setAccessible(true);
    +                resolvedAddresses = InetAddress.getAllByName((String) m.invoke(address));
    +            } catch (IllegalAccessException e) {
    +                resolvedAddresses = InetAddress.getAllByName(getHostString(address));
    +            } catch (NoSuchMethodException e) {
    +                resolvedAddresses = InetAddress.getAllByName(getHostString(address));
    +            } catch (InvocationTargetException e) {
    +                resolvedAddresses = InetAddress.getAllByName(getHostString(address));
    +            }
    --- End diff --
    
    That's possibly another issue with this way of exposing `getHostString, the presence of
a security manager could prevent us from doing it as expected.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message