elharo opened a new pull request, #387:
URL: https://github.com/apache/maven-shared-utils/pull/387

   `StreamPollFeeder.done` and `StreamPollFeeder.exception` are accessed from 
multiple threads without `volatile`, violating the Java Memory Model.
   
   **`done`** (line 40): read in `run()` outside any `synchronized` block (line 
61), written in `waitUntilDone()` inside `synchronized (lock)` (line 107). When 
the feeder thread is continuously reading data (`input.available() > 0`), it 
never enters the `synchronized` block, so no happens‑before guarantees the 
write to `done` is ever seen. The thread loops forever and `waitUntilDone()`'s 
`join()` call hangs.
   
   **`exception`** (line 38): written by the `run()` thread (lines 79, 92) and 
read from other threads via `getException()` (line 101). Without `volatile`, a 
thread calling `getException()` may see a stale `null`. `StreamPumper` already 
declares its equivalent field as `volatile` — `StreamPollFeeder` should follow 
the same pattern.
   
   Fixes https://github.com/apache/maven-shared-utils/issues/385
   Fixes https://github.com/apache/maven-shared-utils/issues/386


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