diff --git a/dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtil.java b/dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtil.java index e56020f5..fd017d3a 100644 --- a/dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtil.java +++ b/dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtil.java @@ -177,7 +177,7 @@ protected Optional>> getSearchResultsExcludi Optional>> contentsForOrgWithMaximumHits; contentsForOrgWithMaximumHits = findFilesWithImage(image, orgsToInclude, gitApiSearchLimit); - final Map orgsToExcludeFromSearch = new HashMap(orgsToExclude); + final Map orgsToExcludeFromSearch = new HashMap<>(orgsToExclude); orgsToExcludeFromSearch.put(orgWithMaximumHits, false); log.info("Running search by excluding the orgs {}.", orgsToExcludeFromSearch.keySet()); Optional>> contentsExcludingOrgWithMaximumHits; diff --git a/dockerfile-image-update/src/test/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtilTest.java b/dockerfile-image-update/src/test/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtilTest.java index 5edf14c8..4e58c1a4 100644 --- a/dockerfile-image-update/src/test/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtilTest.java +++ b/dockerfile-image-update/src/test/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtilTest.java @@ -330,6 +330,7 @@ public void getSearchResultsExcludingOrgWithMostHits() throws Exception { Map orgsToIncludeOrExclude = new HashMap<>(); assertEquals((dockerfileGitHubUtil.getSearchResultsExcludingOrgWithMostHits("image", contentsWithImage, orgsToIncludeOrExclude, 1000)).get().size(), 2); + //This check ensures that the parameter passed to the method is not modified. Instead, the method creates a local copy of the map and modifies that. assertEquals(orgsToIncludeOrExclude.size(), 0); }