elharo opened a new issue, #12591:
URL: https://github.com/apache/maven/issues/12591

   # DefaultProfileInjector: Non-atomic computeIfAbsent on synchronized 
WeakHashMap
   
   **Found in:** maven-4.0.x branch
   **File:** 
`impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultProfileInjector.java`
 (lines 56, 68-70)
   **Severity:** High
   
   ## Description
   
   `Collections.synchronizedMap()` only synchronizes individual method calls, 
but `computeIfAbsent()` is a compound operation. Since `WeakHashMap` does not 
override `computeIfAbsent()`, two threads can execute the inner map creation 
concurrently:
   
   ```java
   Model result = CACHE.computeIfAbsent(model, k -> new ConcurrentHashMap<>())
           .computeIfAbsent(profiles, l -> doInjectProfiles(model, profiles));
   ```
   
   One thread's inner `ConcurrentHashMap` can be discarded (and its profile 
results lost). This causes profile injection cache inconsistency under 
concurrent model building in multi-module reactor builds.


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