Skip to content

Commit 17d4e66

Browse files
committed
Accepted workaround
1 parent eef3490 commit 17d4e66

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,18 @@ public void shouldHonorUDPPorts() {
162162
GenericContainer container = new GenericContainer<>(image)
163163
.withExposedPorts(8080, 8081)
164164
.withCreateContainerCmdModifier(cmd -> {
165-
//Add previously exposed ports
166-
List<ExposedPort> ports = new ArrayList<>();
165+
//Add previously exposed ports and UDP port
166+
List<ExposedPort> exposedPorts = new ArrayList<>();
167167
for (ExposedPort p : cmd.getExposedPorts()) {
168-
ports.add(p);
168+
exposedPorts.add(p);
169169
}
170-
//Add and expose UDP port
171-
ports.add(ExposedPort.udp(99));
172-
cmd.withExposedPorts(ports);
170+
exposedPorts.add(ExposedPort.udp(99));
171+
cmd.withExposedPorts(exposedPorts);
172+
173+
//Add previous port bindings and UDP port binding
174+
Ports ports = cmd.getPortBindings();
175+
ports.bind(ExposedPort.udp(99), Ports.Binding.empty());
176+
cmd.withPortBindings(ports);
173177
}
174178
)
175179
) {

0 commit comments

Comments
 (0)