Skip to content

Commit 4cb096e

Browse files
authored
sonar: loop on entrySet instead of keySet (#3401)
Fix sonar issue: "entrySet()" should be iterated when both the key and value are needed
1 parent 6137616 commit 4cb096e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ public JibContainerBuilder toContainerBuilder() throws IOException {
598598
LayerType.DEPENDENCIES, addedDependencies,
599599
LayerType.SNAPSHOT_DEPENDENCIES, addedSnapshotDependencies,
600600
LayerType.PROJECT_DEPENDENCIES, addedProjectDependencies);
601-
for (LayerType layerType : layerMap.keySet()) {
602-
for (Path file : Preconditions.checkNotNull(layerMap.get(layerType))) {
601+
for (Map.Entry<LayerType, List<Path>> entry : layerMap.entrySet()) {
602+
for (Path file : Preconditions.checkNotNull(entry.getValue())) {
603603
// Handle duplicates by appending filesize to the end of the file. This renaming logic
604604
// must be in sync with the code that does the same in the other place. See
605605
// https://github.com/GoogleContainerTools/jib/issues/3331
@@ -610,7 +610,7 @@ public JibContainerBuilder toContainerBuilder() throws IOException {
610610
// Add dependencies to layer configuration
611611
addFileToLayer(
612612
layerBuilders,
613-
layerType,
613+
entry.getKey(),
614614
file,
615615
appRoot.resolve(dependenciesDestination).resolve(jarName));
616616
}

0 commit comments

Comments
 (0)