Skip to content

Commit e841f76

Browse files
committed
make exposing host ports work when used together with a reusable container
1 parent 6a9355f commit e841f76

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

core/src/test/java/org/testcontainers/containers/ExposedHostTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
public class ExposedHostTest {
2424

2525
private static HttpServer server;
26+
2627
private static Network network;
2728

2829
@BeforeClass
@@ -190,23 +191,25 @@ private static Network createReusableNetwork(UUID name) {
190191
.listNetworksCmd()
191192
.exec()
192193
.stream()
193-
.filter(network ->
194-
network.getName().equals(name.toString()) &&
195-
network.getLabels().equals(DockerClientFactory.DEFAULT_LABELS)
196-
)
194+
.filter(network -> {
195+
return (
196+
network.getName().equals(name.toString()) &&
197+
network.getLabels().equals(DockerClientFactory.DEFAULT_LABELS)
198+
);
199+
})
197200
.map(com.github.dockerjava.api.model.Network::getId)
198201
.findFirst()
199-
.orElseGet(() ->
200-
DockerClientFactory
202+
.orElseGet(() -> {
203+
return DockerClientFactory
201204
.instance()
202205
.client()
203206
.createNetworkCmd()
204207
.withName(name.toString())
205208
.withCheckDuplicate(true)
206209
.withLabels(DockerClientFactory.DEFAULT_LABELS)
207210
.exec()
208-
.getId()
209-
);
211+
.getId();
212+
});
210213

211214
return new Network() {
212215
@Override

0 commit comments

Comments
 (0)