You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2020/04/03 17:27:15 UTC

[GitHub] [bookkeeper] sijie commented on a change in pull request #2301: Handle NPE when inet address is not able to resolve network address

sijie commented on a change in pull request #2301: Handle NPE when inet address is not able to resolve network address
URL: https://github.com/apache/bookkeeper/pull/2301#discussion_r403171533
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/net/NetUtils.java
 ##########
 @@ -68,13 +68,20 @@ public static String normalizeHostName(String name) {
         return hostNames;
     }
 
-    public static String resolveNetworkLocation(DNSToSwitchMapping dnsResolver, InetSocketAddress addr) {
+    public static String resolveNetworkLocation(DNSToSwitchMapping dnsResolver,
+                                                BookieSocketAddress addr) {
         List<String> names = new ArrayList<String>(1);
 
+        InetSocketAddress inetSocketAddress = addr.getSocketAddress();
         if (dnsResolver.useHostName()) {
             names.add(addr.getHostName());
         } else {
-            names.add(addr.getAddress().getHostAddress());
+            InetAddress inetAddress = inetSocketAddress.getAddress();
+            if (null == inetAddress) {
+                addr.getHostName();
 
 Review comment:
   We need to add it to `names`. I will fix it.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services