HDFS-3944. Httpfs resolveAuthority() is not resolving host correctly. (tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1386994 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2012-09-18 05:45:57 +00:00
parent 37d5618742
commit c419b1385d
3 changed files with 25 additions and 1 deletions

View File

@ -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) {

View File

@ -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());
}
}

View File

@ -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