diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/servlet/ServerWebApp.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/servlet/ServerWebApp.java index b040054267f..3db0f5568f4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/servlet/ServerWebApp.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/servlet/ServerWebApp.java @@ -181,7 +181,7 @@ public abstract class ServerWebApp extends Server implements ServletContextListe throw new ServerException(ServerException.ERROR.S13, portKey); } try { - InetAddress add = InetAddress.getByName(hostnameKey); + InetAddress add = InetAddress.getByName(host); int portNum = Integer.parseInt(port); return new InetSocketAddress(add, portNum); } catch (UnknownHostException ex) { diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/servlet/TestServerWebApp.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/servlet/TestServerWebApp.java index 0234266e4ac..889d20b7584 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/servlet/TestServerWebApp.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/servlet/TestServerWebApp.java @@ -24,8 +24,11 @@ import org.apache.hadoop.lib.server.Server; import org.apache.hadoop.test.HTestCase; import org.apache.hadoop.test.TestDir; import org.apache.hadoop.test.TestDirHelper; +import org.junit.Assert; import org.junit.Test; +import java.net.InetSocketAddress; + public class TestServerWebApp extends HTestCase { @Test(expected = IllegalArgumentException.class) @@ -74,4 +77,23 @@ public class TestServerWebApp extends HTestCase { server.contextInitialized(null); } + + @Test + @TestDir + public void testResolveAuthority() throws Exception { + String dir = TestDirHelper.getTestDir().getAbsolutePath(); + System.setProperty("TestServerWebApp3.home.dir", dir); + System.setProperty("TestServerWebApp3.config.dir", dir); + System.setProperty("TestServerWebApp3.log.dir", dir); + System.setProperty("TestServerWebApp3.temp.dir", dir); + System.setProperty("testserverwebapp3.http.hostname", "localhost"); + System.setProperty("testserverwebapp3.http.port", "14000"); + ServerWebApp server = new ServerWebApp("TestServerWebApp3") { + }; + + InetSocketAddress address = server.resolveAuthority(); + Assert.assertEquals("localhost", address.getHostName()); + Assert.assertEquals(14000, address.getPort()); + } + } diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 28e8ec92845..3eeede27370 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -773,6 +773,8 @@ Release 2.0.2-alpha - 2012-09-07 HDFS-3928. MiniDFSCluster should reset the first ExitException on shutdown. (eli) HDFS-3938. remove current limitations from HttpFS docs. (tucu) + + HDFS-3944. Httpfs resolveAuthority() is not resolving host correctly. (tucu) BREAKDOWN OF HDFS-3042 SUBTASKS