damccorm opened a new pull request, #41772:
URL: https://github.com/apache/beam/pull/41772

   ### Summary
   Fixes a test-only data race detected by ThreadSanitizer in 
`WatermarkEstimatorsTest.testThreadSafeWatermarkEstimator`.
   
   ### Root Cause
   `testThreadSafeWatermarkEstimator` used a plain single-element `Instant[]` 
(`reference`) to simulate an external watermark source updated by a competing 
thread:
   - The test thread read `reference[0]` inside 
`WatermarkEstimator.currentWatermark()` while holding the 
`ThreadSafeWatermarkEstimator` monitor.
   - The updater thread wrote `reference[0] = instant` directly without any 
synchronization, bypassing the wrapper monitor and creating a Java Memory Model 
data race.
   
   (Unlike `TimestampObservingWatermarkEstimator` and 
`ManualWatermarkEstimator`, the base `WatermarkEstimator` interface has no 
mutator method; real implementations such as `WallTime` read from a thread-safe 
source.)
   
   ### Change
   - Replace `Instant[] reference` with `AtomicReference<Instant> reference`, 
using `reference.get()` and `reference::set`.
   
   ### Testing
   - Compiled and ran `WatermarkEstimatorsTest` locally via `JUnitCore` (2/2 
tests passing).


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