Skip to content

Commit ce7693e

Browse files
Change external port check so it can timeout and retry (#4680)
Co-authored-by: Sergei Egorov <[email protected]>
1 parent cd04914 commit ce7693e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/main/java/org/testcontainers/containers/wait/internal/ExternalPortListeningCheck.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.testcontainers.containers.ContainerState;
55

66
import java.io.IOException;
7+
import java.net.InetSocketAddress;
78
import java.net.Socket;
89
import java.util.Set;
910
import java.util.concurrent.Callable;
@@ -21,8 +22,9 @@ public Boolean call() {
2122
String address = containerState.getHost();
2223

2324
externalLivenessCheckPorts.parallelStream().forEach(externalPort -> {
24-
try {
25-
new Socket(address, externalPort).close();
25+
try (Socket socket = new Socket()) {
26+
InetSocketAddress inetSocketAddress = new InetSocketAddress(address, externalPort);
27+
socket.connect(inetSocketAddress, 1000);
2628
} catch (IOException e) {
2729
throw new IllegalStateException("Socket not listening yet: " + externalPort);
2830
}

0 commit comments

Comments
 (0)