The GitHub Actions job "CodeQL" on 
commons-math.git/fix/synchronized-descriptive-statistics-mutators has failed.
Run started by GitHub user Lyin-OTTF (triggered by Lyin-OTTF).

Head commit for run:
fda0a8a3215e9f51a33f26c2cb4b663f747eaab5 / Lyin-OTTF <[email protected]>
Synchronize the remaining mutators of SynchronizedDescriptiveStatistics

SynchronizedDescriptiveStatistics documents that modification and access
methods are atomic operations for a single instance, but it only overrides
twelve of the inherited methods. removeMostRecentValue() and
replaceMostRecentValue(double) were not among them, so these two mutators
updated the storeless statistics without holding the instance monitor - the
sibling SynchronizedSummaryStatistics does cover every mutator.

A getValues() or getMean() call locks the monitor and copies or computes
over the store, so it can now run concurrently with a replace in flight; and
a remove can interleave with add so that the discarded value is not the one
the caller observed. Both violate the class contract and can produce an
inconsistent snapshot rather than an exception.

Add synchronized overrides for both methods. The new tests hold the instance
monitor and run the mutator on another thread: a synchronized method stays
blocked until the monitor is released, whereas the previous implementation
returned immediately. A reflection test asserts that every mutator of
DescriptiveStatistics is declared synchronized in the wrapper, so a mutator
added later cannot silently regress.

Report URL: https://github.com/apache/commons-math/actions/runs/39261952985

With regards,
GitHub Actions via GitBox

Reply via email to