arturobernalg opened a new pull request, #769:
URL: https://github.com/apache/maven-pmd-plugin/pull/769

   Fixes #656.
   
   `net.sourceforge.pmd.benchmark.TimeTracker` tracks one global, non-reentrant 
timer per JVM, not one per caller. `PmdExecutor.run()` executes in-process (no 
fork) unless a JDK toolchain forces one, so in a multi-module reactor build run 
with parallel building (`-T`), every module's benchmarked run shares the same 
JVM and calls `TimeTracker.startGlobalTracking()`/`stopGlobalTracking()` 
against that same global state with no coordination. One module's call can 
reset or stop the tracking another module's run depends on, and 
`stopGlobalTracking()` returns `null` for whichever call loses the race, so 
`writeBenchmarkReport()` NPEs trying to render it - exactly the trace in the 
issue.
   
   Wrapping the benchmarked section (tracker start, the PMD run, tracker stop, 
and writing the report) in a lock serializes it across modules when 
benchmarking is requested, while leaving everything else - including 
non-benchmarked runs - exactly as parallel as before, since each of those 
threads locks on a private object of its own instead of the shared one.
   
   Added an integration test (`MPMD-656-parallel-benchmark`) with 4 modules and 
benchmark enabled, built with `-T4`: reproduced the NullPointerException from 
the issue reliably before the fix, and confirmed every module now gets its own 
non-empty benchmark report.
   
   Full test suite, checkstyle, spotless and rat pass locally.
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [x] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to