Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid HashMap concurrent access issue in dependency-version-check-work executor service #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

weijiequ
Copy link

@weijiequ weijiequ commented Jul 5, 2022

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.

…ker service

Details:
resolverMap is used in an executorService 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.
@weijiequ
Copy link
Author

weijiequ commented Jul 5, 2022

Hi @hgschmie, how are you doing? Not sure if you remember the weird dependency plugin failures in CI build years back. This is the RCA and fix -:)

@electrum
Copy link
Contributor

electrum commented Jul 5, 2022

The new version of the plugin is here: https://github.com/basepom/dependency-versions-check-maven-plugin

Maybe @brianm could update the README and archive this repository?

@weijiequ
Copy link
Author

weijiequ commented Jul 5, 2022

thanks @electrum! However, we are still on the basepom8 and that repo still points to this ning plugin.

https://github.com/basepom/basepom/blob/basepom8/foundation/pom.xml#L467-L476

@hgschmie
Copy link
Contributor

hgschmie commented Jul 8, 2022

Hey @weijiequ! How is Beijing these days?

If you choose to use a newer JDK to build (you should), you can use JDK11+ for building with JDK8 as the target.

I am not sure that I can still build and release this repository.

@weijiequ
Copy link
Author

I am doing well, thanks @hgschmie !

Yes, agree. I think we can plan for a JDK upgrade and stick to the latest basepom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants