From baf0901b3a9735cd31c7e946d0a5be780ff9c4f4 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 30 Mar 2015 20:50:14 +0200 Subject: [PATCH] test: adjusted find available port loop Original commit: elastic/x-pack-elasticsearch@ae44c570c0e7d15cf44c6b01c027cdc533390589 --- .../watcher/support/http/HttpClientTest.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/elasticsearch/watcher/support/http/HttpClientTest.java b/src/test/java/org/elasticsearch/watcher/support/http/HttpClientTest.java index c6b5770043f..71b3ae2c1eb 100644 --- a/src/test/java/org/elasticsearch/watcher/support/http/HttpClientTest.java +++ b/src/test/java/org/elasticsearch/watcher/support/http/HttpClientTest.java @@ -34,20 +34,17 @@ public class HttpClientTest extends ElasticsearchTestCase { @Before public void init() throws Exception { - while (webPort < 9300) { + for (; webPort < 9300; webPort++) { try { webServer = new MockWebServer(); webServer.start(webPort); - break; + httpClient = new HttpClient(ImmutableSettings.EMPTY); + return; } catch (BindException be) { logger.warn("port [{}] was already in use trying next port", webPort); - ++webPort; } } - if (webPort == 9300) { - throw new ElasticsearchException("unable to find open port between 9200 and 9300"); - } - httpClient = new HttpClient(ImmutableSettings.EMPTY); + throw new ElasticsearchException("unable to find open port between 9200 and 9300"); } @After