Source:
protected void waitUntilReady() { final String containerName = waitStrategyTarget.getContainerInfo().getName(); final Integer livenessCheckPort = livenessPort.map(waitStrategyTarget::getMappedPort).orElseGet(() -> { final Set<Integer> livenessCheckPorts = getLivenessCheckPorts(); if (livenessCheckPorts == null || livenessCheckPorts.isEmpty()) { log.warn("{}: No exposed ports or mapped ports - cannot wait for status", containerName); return -1; } return livenessCheckPorts.iterator().next(); }); if (null == livenessCheckPort || -1 == livenessCheckPort) { return; } final String uri = buildLivenessUri(livenessCheckPort).toString(); log.info("{}: Waiting for seconds for URL: {}", containerName, startupTimeout.getSeconds(), uri); try { retryUntilSuccess((int) startupTimeout.getSeconds(), TimeUnit.SECONDS, () -> { getRateLimiter().doWhenReady(() -> { try { final HttpURLConnection connection = (HttpURLConnection) new URL(uri).openConnection(); if (!Strings.isNullOrEmpty(username)) { connection.setRequestProperty(HEADER_AUTHORIZATION, buildAuthString(username, password)); connection.setUseCaches(false); } connection.setRequestMethod("GET"); connection.connect(); log.info("Get response code {}", connection.getResponseCode()); if (!statusCodePredicate.test(connection.getResponseCode())) { throw new RuntimeException(String.format("HTTP response code was: %s", connection.getResponseCode())); } if(responsePredicate != null) { String responseBody = getResponseBody(connection); log.info("Get response {}", responseBody); if(!responsePredicate.test(responseBody)) { throw new RuntimeException(String.format("Response: %s did not match predicate", responseBody)); } } } catch (IOException e) { throw new RuntimeException(e); } }); return true; }); } catch (TimeoutException e) { throw new ContainerLaunchException(String.format( "Timed out waiting for URL to be accessible (%s should return HTTP %s)", uri, statusCodes.isEmpty() ? HttpURLConnection.HTTP_OK : statusCodes)); } }

Target:
protected void waitUntilReady() { final String containerName = waitStrategyTarget.getContainerInfo().getName(); final Integer livenessCheckPort = livenessPort.map(waitStrategyTarget::getMappedPort).orElseGet(() -> { final Set<Integer> livenessCheckPorts = getLivenessCheckPorts(); if (livenessCheckPorts == null || livenessCheckPorts.isEmpty()) { log.warn("{}: No exposed ports or mapped ports - cannot wait for status", containerName); return -1; } return livenessCheckPorts.iterator().next(); }); if (null == livenessCheckPort || -1 == livenessCheckPort) { return; } final String uri = buildLivenessUri(livenessCheckPort).toString(); log.info("{}: Waiting for seconds for URL: {}", containerName, startupTimeout.getSeconds(), uri); try { retryUntilSuccess((int) startupTimeout.getSeconds(), TimeUnit.SECONDS, () -> { getRateLimiter().doWhenReady(() -> { try { final HttpURLConnection connection = (HttpURLConnection) new URL(uri).openConnection(); if (!Strings.isNullOrEmpty(username)) { connection.setRequestProperty(HEADER_AUTHORIZATION, buildAuthString(username, password)); connection.setUseCaches(false); } connection.setRequestMethod("GET"); connection.connect(); log.trace("Get response code {}", connection.getResponseCode()); if (!statusCodePredicate.test(connection.getResponseCode())) { throw new RuntimeException(String.format("HTTP response code was: %s", connection.getResponseCode())); } if(responsePredicate != null) { String responseBody = getResponseBody(connection); log.trace("Get response {}", responseBody); if(!responsePredicate.test(responseBody)) { throw new RuntimeException(String.format("Response: %s did not match predicate", responseBody)); } } } catch (IOException e) { throw new RuntimeException(e); } }); return true; }); } catch (TimeoutException e) { throw new ContainerLaunchException(String.format( "Timed out waiting for URL to be accessible (%s should return HTTP %s)", uri, statusCodes.isEmpty() ? HttpURLConnection.HTTP_OK : statusCodes)); } }