Fix for duplicate key violation for exposed ports by ctoestreich · Pull Request #1392 · docker-java/docker-java

Conversation

@ctoestreich

Found an issue where ports are being added duplicately to the map and causing an exception. I am still investigating how this situation arose, but this code will prevent the exception.

@ctoestreich

The test failures appear to be unrelated and on mainline.

@bsideup

@ctoestreich please sync with the latest master to fix the CI

bsideup

public Map<String, Object> toPrimitive() {
return Stream.of(exposedPorts).collect(Collectors.toMap(
return Stream.of(exposedPorts)
.distinct()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of distinct(), we can use a merge strategy (3rd argument of toMap) that does not throw, but uses the previously set value

@bsideup

@ctoestreich could you please allow maintainers to make edits? (there is a checkbox in PR's settings)

@ctoestreich

@bsideup looking for checkbox to allow don’t see it atm.

@ctoestreich

Nope not on screen and not avail after close or reopen.

@bsideup

@ctoestreich

@bsideup

@ctoestreich ok, this is weird :D Could you please apply the change then? (3rd argument of toMap instead of distinct)

@bsideup

2 participants

@ctoestreich @bsideup