gnodet commented on PR #427:
URL: 
https://github.com/apache/maven-install-plugin/pull/427#issuecomment-5445668844

   The race condition identified by @mfriedenhagen and reproduced by @skrcode 
is now fixed.
   
   **What changed:** the `get` / `null-check` / `put` on the plugin context map 
is wrapped in `synchronized (ctx)` so only the first thread in a parallel build 
(`-T`) computes the reactor scan — all others reuse the cached result.
   
   **Why `synchronized` over `computeIfAbsent`:** `Session.getPluginContext()` 
returns `Map`, not `ConcurrentMap`. Casting to `ConcurrentMap` would depend on 
the underlying implementation (`DefaultSession` uses `ConcurrentHashMap` today, 
but the API doesn't guarantee it). The `synchronized` block is the safest 
choice and the contention is negligible — after the first fill, every 
subsequent call is just a `get()` + null-check inside an uncontended monitor.
   
   All 14 existing tests pass.


-- 
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