ivankelly closed pull request #1295: Issue #1287: NPE at DNS.reverse
URL: https://github.com/apache/bookkeeper/pull/1295
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/net/DNS.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/net/DNS.java
index 6ae5a8177..308728e7b 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/net/DNS.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/net/DNS.java
@@ -28,6 +28,7 @@
 import java.util.Vector;
 
 import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.InitialDirContext;
@@ -87,7 +88,20 @@ public static String reverseDns(InetAddress hostIp, String 
ns)
             ictx.close();
         }
 
-        return attribute.get("PTR").get().toString();
+        if (null == attribute) {
+            throw new NamingException("No attribute is found");
+        }
+
+        Attribute ptrAttr = attribute.get("PTR");
+        if (null == ptrAttr) {
+            throw new NamingException("No PTR attribute is found");
+        }
+
+        if (null == ptrAttr.get()) {
+            throw new NamingException("PTR attribute value is null");
+        }
+
+        return ptrAttr.get().toString();
     }
 
     /**


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to