test: adjusted find available port loop

Original commit: elastic/x-pack-elasticsearch@ae44c570c0
This commit is contained in:
Martijn van Groningen 2015-03-30 20:50:14 +02:00
parent 06efbf1481
commit baf0901b3a
1 changed files with 4 additions and 7 deletions

View File

@ -34,20 +34,17 @@ public class HttpClientTest extends ElasticsearchTestCase {
@Before @Before
public void init() throws Exception { public void init() throws Exception {
while (webPort < 9300) { for (; webPort < 9300; webPort++) {
try { try {
webServer = new MockWebServer(); webServer = new MockWebServer();
webServer.start(webPort); webServer.start(webPort);
break; httpClient = new HttpClient(ImmutableSettings.EMPTY);
return;
} catch (BindException be) { } catch (BindException be) {
logger.warn("port [{}] was already in use trying next port", webPort); 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");
throw new ElasticsearchException("unable to find open port between 9200 and 9300");
}
httpClient = new HttpClient(ImmutableSettings.EMPTY);
} }
@After @After