From 4dac9a60ef84c7b964fbbd4564ffbea7e75434b7 Mon Sep 17 00:00:00 2001 From: Aaron Myers Date: Thu, 7 Mar 2013 23:51:43 +0000 Subject: [PATCH] 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-2@1454173 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/net/DNS.java | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 1f925bf9a5f..c0feff3f866 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -71,6 +71,9 @@ Release 2.0.5-beta - UNRELEASED HADOOP-9337. org.apache.hadoop.fs.DF.getMount() does not work on Mac OS. (Ivan A. Veselovsky via atm) + HADOOP-9369. DNS#reverseDns() can return hostname with . appended at the + end. (Karthik Kambatla via atm) + Release 2.0.4-alpha - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNS.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNS.java index 73bbd4a6314..f19e80235b3 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNS.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNS.java @@ -89,7 +89,12 @@ public class DNS { 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; } /**