You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by ya...@apache.org on 2015/09/15 00:55:11 UTC
samza git commit: SAMZA-770: HttpServer uses getHostAddress instead
of getHostName to build URL
Repository: samza
Updated Branches:
refs/heads/master 1aee39ff1 -> 3fb8d6f41
SAMZA-770: HttpServer uses getHostAddress instead of getHostName to build URL
Project: http://git-wip-us.apache.org/repos/asf/samza/repo
Commit: http://git-wip-us.apache.org/repos/asf/samza/commit/3fb8d6f4
Tree: http://git-wip-us.apache.org/repos/asf/samza/tree/3fb8d6f4
Diff: http://git-wip-us.apache.org/repos/asf/samza/diff/3fb8d6f4
Branch: refs/heads/master
Commit: 3fb8d6f41199815083c25452d3442fca7110f8d8
Parents: 1aee39f
Author: Michael Martin <mw...@gmail.com>
Authored: Mon Sep 14 15:54:43 2015 -0700
Committer: Yan Fang <ya...@gmail.com>
Committed: Mon Sep 14 15:54:43 2015 -0700
----------------------------------------------------------------------
.../apache/samza/coordinator/server/HttpServer.scala | 3 ++-
.../samza/coordinator/server/TestHttpServer.scala | 13 +++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/samza/blob/3fb8d6f4/samza-core/src/main/scala/org/apache/samza/coordinator/server/HttpServer.scala
----------------------------------------------------------------------
diff --git a/samza-core/src/main/scala/org/apache/samza/coordinator/server/HttpServer.scala b/samza-core/src/main/scala/org/apache/samza/coordinator/server/HttpServer.scala
index c93f270..06ca773 100644
--- a/samza-core/src/main/scala/org/apache/samza/coordinator/server/HttpServer.scala
+++ b/samza-core/src/main/scala/org/apache/samza/coordinator/server/HttpServer.scala
@@ -130,7 +130,8 @@ class HttpServer(
def getUrl = {
if (running) {
val runningPort = server.getConnectors()(0).asInstanceOf[Connector].getLocalPort()
- new URL("http://" + Util.getLocalHost.getHostAddress + ":" + runningPort + rootPath)
+
+ new URL("http://" + Util.getLocalHost.getHostName + ":" + runningPort + rootPath)
} else {
throw new SamzaException("HttpServer is not currently running, so URLs are not available for it.")
}
http://git-wip-us.apache.org/repos/asf/samza/blob/3fb8d6f4/samza-core/src/test/scala/org/apache/samza/coordinator/server/TestHttpServer.scala
----------------------------------------------------------------------
diff --git a/samza-core/src/test/scala/org/apache/samza/coordinator/server/TestHttpServer.scala b/samza-core/src/test/scala/org/apache/samza/coordinator/server/TestHttpServer.scala
index 6ce8aa9..f1dcc3d 100644
--- a/samza-core/src/test/scala/org/apache/samza/coordinator/server/TestHttpServer.scala
+++ b/samza-core/src/test/scala/org/apache/samza/coordinator/server/TestHttpServer.scala
@@ -23,6 +23,7 @@ import org.apache.samza.util.Util
import org.junit.Assert._
import org.junit.Test
import java.net.URL
+import org.eclipse.jetty.server.Connector
class TestHttpServer {
@Test
@@ -39,6 +40,18 @@ class TestHttpServer {
server.stop
}
}
+
+ @Test
+ def testHttpServerUrl {
+ val server = new HttpServer("/test", resourceBasePath = "scalate")
+ try {
+ server.addServlet("/basic", new BasicServlet())
+ server.start
+ assertTrue(server.getUrl.getHost == Util.getLocalHost.getHostName)
+ } finally {
+ server.stop
+ }
+ }
}
class BasicServlet extends ServletBase {