From 425d5a1aedc17da35a523b7c1f4ca7c142bb05a8 Mon Sep 17 00:00:00 2001 From: "James X. Nelson" Date: Fri, 29 Jun 2018 08:07:28 -0700 Subject: [PATCH] Fix livelock from concurrent use of HashMap --- .../plugins/license/maven/AbstractLicenseMojo.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/groovy/nl/javadude/gradle/plugins/license/maven/AbstractLicenseMojo.java b/src/main/groovy/nl/javadude/gradle/plugins/license/maven/AbstractLicenseMojo.java index b45b0b6..ca2c491 100644 --- a/src/main/groovy/nl/javadude/gradle/plugins/license/maven/AbstractLicenseMojo.java +++ b/src/main/groovy/nl/javadude/gradle/plugins/license/maven/AbstractLicenseMojo.java @@ -37,13 +37,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.concurrent.CompletionService; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; @@ -187,8 +187,8 @@ public void run() { * From com/google/code/mojo/license/AbstractLicenseMojo.java */ protected final Map mergeProperties() { - // first put syste environment - Map props = new HashMap(System.getenv()); + // first put system environment + Map props = new ConcurrentHashMap(System.getenv()); // Override with extension props.putAll(initial); @@ -201,8 +201,8 @@ protected final Map mergeProperties() { } private Map buildMapping(Map headerDefinitions) { - Map extensionMapping = useDefaultMappings ? new HashMap(defaultMapping()) - : new HashMap(); + Map extensionMapping = useDefaultMappings ? new ConcurrentHashMap(defaultMapping()) + : new ConcurrentHashMap(); List headerTypes = Arrays.asList(HeaderType.values()); Set validHeaderTypes = new HashSet(); @@ -228,7 +228,7 @@ private Map buildMapping(Map headerDefi private Map buildHeaderDefinitions() { // like mappings, first get default definitions - final Map headers = new HashMap( + final Map headers = new ConcurrentHashMap( HeaderType.defaultDefinitions()); // Add additional header definitions