Browse Source

HADOOP-9369. DNS#reverseDns() can return hostname with . appended at the end. Contributed by Karthik Kambatla.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1454176 13f79535-47bb-0310-9956-ffa450edef68
Aaron Myers 12 years ago
parent
commit
5c4f6c0f38
2 changed files with 9 additions and 1 deletions
  1. 3 0
      CHANGES.txt
  2. 6 1
      src/core/org/apache/hadoop/net/DNS.java

+ 3 - 0
CHANGES.txt

@@ -534,6 +534,9 @@ Release 1.2.0 - unreleased
     MAPREDUCE-5049. CombineFileInputFormat counts all compressed files 
     non-splitable. (sandyr via tucu)
 
+    HADOOP-9369. DNS#reverseDns() can return hostname with . appended at the
+    end. (Karthik Kambatla via atm)
+
 Release 1.1.2 - 2013.01.30
 
   INCOMPATIBLE CHANGES

+ 6 - 1
src/core/org/apache/hadoop/net/DNS.java

@@ -76,7 +76,12 @@ public class DNS {
                          "/" + reverseIP, new String[] { "PTR" });
     ictx.close();
     
-    return attribute.get("PTR").get().toString();
+    String hostname = attribute.get("PTR").get().toString();
+    int hostnameLength = hostname.length();
+    if (hostname.charAt(hostnameLength - 1) == '.') {
+      hostname = hostname.substring(0, hostnameLength - 1);
+    }
+    return hostname;
   }
 
   /**