This is an automated email from the ASF dual-hosted git repository.
ivank pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 52cefcf Issue #1287: NPE at DNS.reverse
52cefcf is described below
commit 52cefcfae654e317f341a58da0d0a07e902eefa3
Author: Sijie Guo <[email protected]>
AuthorDate: Tue Mar 27 19:29:45 2018 +0200
Issue #1287: NPE at DNS.reverse
Descriptions of the changes in this PR:
*Problem*
Null value can be returned on retrieving attributes.
*Solution*
If null value is returned, throw NamingException so cached localhost name
is used.
Master Issue: #1287
Author: Sijie Guo <[email protected]>
Reviewers: Enrico Olivelli <[email protected]>
This closes #1295 from sijie/fix_dns_reverse, closes #1287
---
.../src/main/java/org/apache/bookkeeper/net/DNS.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
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 6ae5a81..308728e 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.LinkedHashSet;
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 class DNS {
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();
}
/**
--
To stop receiving notification emails like this one, please contact
[email protected].