Skip to content

Commit f4856a0

Browse files
authored
Rename forListeningPort(int... port) to forListeningPorts(int... ports) (#7425)
1 parent f1b0b07 commit f4856a0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

core/src/main/java/org/testcontainers/containers/wait/strategy/HostPortWaitStrategy.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
@Slf4j
2727
public class HostPortWaitStrategy extends AbstractWaitStrategy {
2828

29-
private int[] port;
29+
private int[] ports;
3030

3131
@Override
3232
@SneakyThrows(InterruptedException.class)
3333
protected void waitUntilReady() {
3434
final Set<Integer> externalLivenessCheckPorts;
35-
if (this.port == null) {
35+
if (this.ports == null || this.ports.length == 0) {
3636
externalLivenessCheckPorts = getLivenessCheckPorts();
3737
if (externalLivenessCheckPorts.isEmpty()) {
3838
if (log.isDebugEnabled()) {
@@ -46,7 +46,7 @@ protected void waitUntilReady() {
4646
} else {
4747
externalLivenessCheckPorts =
4848
Arrays
49-
.stream(this.port)
49+
.stream(this.ports)
5050
.mapToObj(port -> waitStrategyTarget.getMappedPort(port))
5151
.collect(Collectors.toSet());
5252
}
@@ -124,8 +124,8 @@ private Set<Integer> getInternalPorts(Set<Integer> externalLivenessCheckPorts, L
124124
.collect(Collectors.toSet());
125125
}
126126

127-
public HostPortWaitStrategy forPort(int... port) {
128-
this.port = port;
127+
public HostPortWaitStrategy forPorts(int... ports) {
128+
this.ports = ports;
129129
return this;
130130
}
131131
}

core/src/main/java/org/testcontainers/containers/wait/strategy/Wait.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public static HostPortWaitStrategy forListeningPort() {
2626
}
2727

2828
/**
29-
* Convenience method to return a WaitStrategy for an exposed or mapped port.
29+
* Convenience method to return a WaitStrategy for exposed or mapped ports.
3030
*
31-
* @param port the port to check
31+
* @param ports the port to check
3232
* @return the WaitStrategy
3333
*/
34-
public static HostPortWaitStrategy forListeningPort(int... port) {
35-
return new HostPortWaitStrategy().forPort(port);
34+
public static HostPortWaitStrategy forListeningPorts(int... ports) {
35+
return new HostPortWaitStrategy().forPorts(ports);
3636
}
3737

3838
/**

core/src/test/java/org/testcontainers/junit/wait/strategy/HostPortWaitStrategyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static class ExplicitHostPortWaitStrategyTest {
3737
.withExposedPorts()
3838
.withCommand("sh", "-c", "while true; do nc -lp 8080; done")
3939
.withExposedPorts(8080)
40-
.waitingFor(Wait.forListeningPort(8080).withStartupTimeout(Duration.ofSeconds(10)));
40+
.waitingFor(Wait.forListeningPorts(8080).withStartupTimeout(Duration.ofSeconds(10)));
4141

4242
@Test
4343
public void testWaiting() {}

0 commit comments

Comments
 (0)