Skip to content

Commit 123f13a

Browse files
authored
Do not fail on duplicated local image tags. Fixes #2431 (#2692)
* #2431 Correction for an edge case in local image repos (duplicates repo tags) crashing the image pulling * Indentation correction * Indentation correction
1 parent e6930d6 commit 123f13a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

core/src/main/java/org/testcontainers/images/LocalImagesCache.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ private void populateFromList(List<Image> images) {
7979
}
8080

8181
cache.putAll(
82-
Stream.of(repoTags).collect(Collectors.toMap(
83-
DockerImageName::new,
84-
it -> ImageData.from(image)
85-
))
82+
Stream.of(repoTags)
83+
// Protection against some edge case where local image repository tags end up with duplicates
84+
// making toMap crash at merge time.
85+
.distinct()
86+
.collect(Collectors.toMap(
87+
DockerImageName::new,
88+
it -> ImageData.from(image)
89+
))
8690
);
8791
}
8892
}

0 commit comments

Comments
 (0)