Avoid HashMap concurrent access issue in dependency-version-check-work executor service #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Details:
resolverMap is used in an executor service without synchronization. In very rare cases, this plugin reports below concurrent error -
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to java.util.HashMap
at java.util.HashMap.moveRootToFront (HashMap.java:1832)
at java.util.HashMap.treeify (HashMap.java:1949)
at java.util.HashMap.treeifyBin (HashMap.java:772)
at java.util.HashMap.putVal (HashMap.java:644)
at java.util.HashMap.put (HashMap.java:612)
at com.ning.maven.plugins.dependencyversionscheck.AbstractDependencyVersionsMojo.findStrategy (AbstractDependencyVersionsMojo.java:423)
at com.ning.maven.plugins.dependencyversionscheck.AbstractDependencyVersionsMojo.resolveVersion (AbstractDependencyVersionsMojo.java:627)
at com.ning.maven.plugins.dependencyversionscheck.AbstractDependencyVersionsMojo.updateResolutionMapForDep (AbstractDependencyVersionsMojo.java:511)
at com.ning.maven.plugins.dependencyversionscheck.AbstractDependencyVersionsMojo.access-bash00 (AbstractDependencyVersionsMojo.java:88)
at com.ning.maven.plugins.dependencyversionscheck.AbstractDependencyVersionsMojo.run (AbstractDependencyVersionsMojo.java:458)
at java.util.concurrent.Executors.call (Executors.java:511)
at com.google.common.util.concurrent.TrustedListenableFutureTask.runInterruptibly (TrustedListenableFutureTask.java:108)
at com.google.common.util.concurrent.InterruptibleTask.run (InterruptibleTask.java:41)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run (TrustedListenableFutureTask.java:77)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
Also change resolverPatternMap and resolvedDependenciesByName to ConcurrentHashMap for consistency.