From 85638a4d0c051e0afe0bae7e03c5aa0551dc26d5 Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Thu, 23 Feb 2017 09:36:12 +0000 Subject: [PATCH] Minor tweak to test setup. No logical changes Looking up host names can be slow on OS X from Java. Cache the lookup of the host and port to try and speed things up for this test. Perhaps this is why the test is timing out on Travis? --- java/client/test/org/openqa/selenium/ReferrerTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/client/test/org/openqa/selenium/ReferrerTest.java b/java/client/test/org/openqa/selenium/ReferrerTest.java index 7f632b7652bef..585cffd37fd7c 100644 --- a/java/client/test/org/openqa/selenium/ReferrerTest.java +++ b/java/client/test/org/openqa/selenium/ReferrerTest.java @@ -32,6 +32,7 @@ import com.google.common.base.Charsets; import com.google.common.base.Joiner; import com.google.common.base.Objects; +import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.net.HostAndPort; @@ -454,6 +455,7 @@ protected void after() { */ private abstract static class ServerResource extends ExternalResource { protected final Server server; + private HostAndPort hostAndPort; ServerResource() { server = new Server(); @@ -470,7 +472,7 @@ void addHandler(Handler handler) { } HostAndPort getHostAndPort() { - return HostAndPort.fromParts(server.getURI().getHost(), server.getURI().getPort()); + return Preconditions.checkNotNull(hostAndPort); } String getBaseUrl() { @@ -480,6 +482,7 @@ String getBaseUrl() { void start() { try { server.start(); + hostAndPort = HostAndPort.fromParts(server.getURI().getHost(), server.getURI().getPort()); new UrlChecker().waitUntilAvailable(10, TimeUnit.SECONDS, new URL(getBaseUrl())); } catch (Exception e) { throw new RuntimeException(e);