From ba6f1a2ed1301e906450ffed0978f81da806dd83 Mon Sep 17 00:00:00 2001 From: Aaron Myers Date: Wed, 22 Jan 2014 18:10:59 +0000 Subject: [PATCH] HADOOP-10252. HttpServer can't start if hostname is not specified. Contributed by Jimmy Xiang. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1560450 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../main/java/org/apache/hadoop/http/HttpServer.java | 2 +- .../java/org/apache/hadoop/http/TestHttpServer.java | 11 +++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 8a7c704aa5..72685218ce 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -533,6 +533,9 @@ Release 2.4.0 - UNRELEASED HADOOP-10235. Hadoop tarball has 2 versions of stax-api JARs. (tucu) + HADOOP-10252. HttpServer can't start if hostname is not specified. (Jimmy + Xiang via atm) + Release 2.3.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java index fa31331d72..404f95f01b 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java @@ -455,7 +455,7 @@ public HttpServer(String name, String bindAddress, int port, public HttpServer(String name, String bindAddress, int port, boolean findPort, Configuration conf, AccessControlList adminsAcl, Connector connector, String[] pathSpecs) throws IOException { - this(new Builder().setName(name) + this(new Builder().setName(name).hostName(bindAddress) .addEndpoint(URI.create("http://" + bindAddress + ":" + port)) .setFindPort(findPort).setConf(conf).setACL(adminsAcl) .setConnector(connector).setPathSpec(pathSpecs)); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java index 6e5ca47824..d4247dd7dd 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java @@ -524,6 +524,17 @@ public void testRequiresAuthorizationAccess() throws Exception { Assert.assertFalse(HttpServer.isInstrumentationAccessAllowed(context, request, response)); } + @Test + @SuppressWarnings("deprecation") + public void testOldConstructor() throws Exception { + HttpServer server = new HttpServer("test", "0.0.0.0", 0, false); + try { + server.start(); + } finally { + server.stop(); + } + } + @Test public void testBindAddress() throws Exception { checkBindAddress("localhost", 0, false).stop(); // hang onto this one for a bit more testing