Skip to content

Commit

Permalink
Fixed HostPortWaitStrategy throws NumberFormatException when port…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
barrycommins authored and bsideup committed Apr 11, 2018
1 parent fd1a079 commit b5181f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
## UNRELEASED

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

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

public interface ContainerState {
Expand Down Expand Up @@ -127,6 +128,7 @@ default List<Integer> getBoundPortNumbers() {
.map(PortBinding::parse)
.map(PortBinding::getBinding)
.map(Ports.Binding::getHostPortSpec)
.filter(Objects::nonNull)
.map(Integer::valueOf)
.collect(Collectors.toList());
}
Expand Down
4 changes: 3 additions & 1 deletion core/src/test/resources/v2-compose-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
version: '2'
services:
redis:
image: redis
image: redis
ports:
- 6379

0 comments on commit b5181f7

Please sign in to comment.