Skip to content

Commit b5181f7

Browse files
barrycomminsbsideup
authored andcommitted
Fixed HostPortWaitStrategy throws NumberFormatException when port is exposed but not mapped (#640)
* Fixed `HostPortWaitStrategy` throws `NumberFormatException` when port is exposed but not mapped * updated exposed port tests are suggested in code review
1 parent fd1a079 commit b5181f7

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
44
## UNRELEASED
55

66
### Fixed
7+
- Fixed `HostPortWaitStrategy` throws `NumberFormatException` when port is exposed but not mapped [\#640](https://github.com/testcontainers/testcontainers-java/issues/640))
78

89
### Changed
910

core/src/main/java/org/testcontainers/containers/ContainerState.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.ArrayList;
1212
import java.util.List;
1313
import java.util.Map;
14+
import java.util.Objects;
1415
import java.util.stream.Collectors;
1516

1617
public interface ContainerState {
@@ -127,6 +128,7 @@ default List<Integer> getBoundPortNumbers() {
127128
.map(PortBinding::parse)
128129
.map(PortBinding::getBinding)
129130
.map(Ports.Binding::getHostPortSpec)
131+
.filter(Objects::nonNull)
130132
.map(Integer::valueOf)
131133
.collect(Collectors.toList());
132134
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
version: '2'
22
services:
33
redis:
4-
image: redis
4+
image: redis
5+
ports:
6+
- 6379

0 commit comments

Comments
 (0)