waterWang opened a new pull request, #12732:
URL: https://github.com/apache/maven/pull/12732

   ### Problem
   
   `ReflectionValueExtractor` keeps a static `WeakHashMap` class-introspection 
cache that is read and written concurrently from multiple builder threads under 
`-T` (parallel builds). `WeakHashMap` is not thread-safe — concurrent `resize` 
from multiple threads can create circular bucket chains, causing the build to 
hang indefinitely at 100% CPU.
   
   **Observed symptom**: `mvn -T1C` hangs with one core pinned at 100%, thread 
dump shows `WeakHashMap.transfer` in a RUNNABLE state inside `getClassMap()`.
   
   ### Fix
   
   Wrap the `WeakHashMap` with `Collections.synchronizedMap()` to serialize all 
reads and writes. This preserves the weak-reference semantics (classloader GC 
is unaffected) while providing thread safety.
   
   ### Changes
   
   - `ReflectionValueExtractor.java`: wrap `CLASS_MAPS` with 
`Collections.synchronizedMap()`, add `import java.util.Collections`
   
   Fixes #12731


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