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?
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);
