[core] RuleSetFactory: Possible threading issue due to PR#75
A source code analyzer
Brought to you by:
adangel,
juansotuyo
I was able to trivially verify that multi-threading support was not working using the -t option. The RuleChain died fairly quickly with ConcurrentModificationExceptions.
It might be worth adding a Test around this, to try to catch regressions via CI. A forced multi-threaded test of the Java rules against the PMD source aught to 1) not fail, 2) produce consistent results if run 2+ times. Not exactly a robust test, but hopefully stands a chance of catching obvious issues before a release happens.
Alternatively, a series of high volume, high concurrency stress tests, could be done pre-release to try to actively shake out such problems. Running all known Rules against a baseline of source from different open source projects and comparing with previous release numbers/reports could be used to spot 1) threading issues, 2) performance problems, 3) false-positive Rule regressions. The -t and -b options are useful here. I had tried doing this once, but I never completed the effort. I'm not sure if something like this now exists.
I have noticed some performance problems while doing analysis on this bug, I'll try to submit some PR around them when I get a chance.
I am using maven-pmd-plugin 3.6 which defaults to PMD 5.3.5. When switching from PMD 5.3.5 to 5.4.1 I start to get a lot of ConcurrentModificationExceptions (first one below) during the build and eventually the build may hang.
Is there a workaround here? I need 5.4.1 as this is what the current version of PMD plugin for IntelliJ IDEA uses.
build hangs on this:
You're right, these exceptions are occurring probably due to this bug.
There seems no workaround here with maven-pmd-plugin, as the threads-option can't be changed (it defaults to
Runtime.getRuntime().availableProcessors().If you really need PMD 5.4.1 right now, the only option seems to be, to run it from commandline or via ant - the PMDTask for ant also supports the "threads" option. To workaround this threading issue, you'll need to run PMD with the option
-threads 0.I've added a unit test (see 54ce3036) to hopefully prevent the problem in the future. I basically reverted the commit from PR #75.
Under documentation, I added one more paragraph -> see How to write a rule
The fix will be included in the next PMD versions (5.3.7, 5.4.2 and 5.5.0).
@rgustav - Please create a separate bug for the performance issues you've seen. Thanks!
Last edit: Andreas Dangel 2016-04-30