diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 8f665fae99a..b91b29e19d5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -292,6 +292,9 @@ Release 2.4.0 - UNRELEASED HDFS-5922. DN heartbeat thread can get stuck in tight loop. (Arpit Agarwal) + HDFS-6008. Namenode dead node link is giving HTTP error 500. + (Benoy Antony via cnauroth) + Release 2.3.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/JspHelper.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/JspHelper.java index 11b714438df..43759ccb27a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/JspHelper.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/JspHelper.java @@ -147,7 +147,9 @@ public class JspHelper { */ public static final class Url { public static String authority(String scheme, DatanodeID d) { - String fqdn = canonicalize(d.getIpAddr()); + String fqdn = (d.getIpAddr() != null && !d.getIpAddr().isEmpty())? + canonicalize(d.getIpAddr()): + d.getHostName(); if (scheme.equals("http")) { return fqdn + ":" + d.getInfoPort(); } else if (scheme.equals("https")) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/common/TestJspHelper.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/common/TestJspHelper.java index 21d5cd3c6f2..5bb388e4b88 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/common/TestJspHelper.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/common/TestJspHelper.java @@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs.server.common; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import static org.mockito.Mockito.*; @@ -611,5 +612,20 @@ public class TestJspHelper { assertTrue(upgradeStatusReport.getStatusText(true).equals( MessageFormat.format(EXPECTED_NOTF_PATTERN, version))); } + + @Test + public void testAuthority(){ + DatanodeID dnWithIp = new DatanodeID("127.0.0.1", "hostName", null, + 50020, 50075, 50076, 50010); + assertNotNull(JspHelper.Url.authority("http", dnWithIp)); + + DatanodeID dnWithNullIp = new DatanodeID(null, "hostName", null, + 50020, 50075, 50076, 50010); + assertNotNull(JspHelper.Url.authority("http", dnWithNullIp)); + + DatanodeID dnWithEmptyIp = new DatanodeID("", "hostName", null, + 50020, 50075, 50076, 50010); + assertNotNull(JspHelper.Url.authority("http", dnWithEmptyIp)); + } }