Skip to content

Commit

Permalink
Change external port check so it can timeout and retry (#4680)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergei Egorov <bsideup@gmail.com>
  • Loading branch information
kmcgovern-apixio and bsideup committed Nov 17, 2021
1 parent cd04914 commit ce7693e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.testcontainers.containers.ContainerState;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Set;
import java.util.concurrent.Callable;
Expand All @@ -21,8 +22,9 @@ public Boolean call() {
String address = containerState.getHost();

externalLivenessCheckPorts.parallelStream().forEach(externalPort -> {
try {
new Socket(address, externalPort).close();
try (Socket socket = new Socket()) {
InetSocketAddress inetSocketAddress = new InetSocketAddress(address, externalPort);
socket.connect(inetSocketAddress, 1000);
} catch (IOException e) {
throw new IllegalStateException("Socket not listening yet: " + externalPort);
}
Expand Down

0 comments on commit ce7693e

Please sign in to comment.