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,21 +34,18 @@ 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);
}
@After
public void after() throws Exception {