Lyin-OTTF commented on PR #333:
URL: https://github.com/apache/commons-math/pull/333#issuecomment-6286259348

   @aherbert Done in df21ddf.
   
   Synchronized getPercentile in SynchronizedDescriptiveStatistics. 
DescriptiveStatistics.getPercentile sets the quantile on the shared percentile 
impl and then calls apply, which is synchronized on the wrapper; without 
synchronizing the whole method another thread could swap the quantile between 
the setQuantile and the apply, so a caller could compute a percentile for a 
quantile it never requested. The override makes both steps atomic against the 
other synchronized methods.
   
   Added two tests: one asserts getPercentile is declared synchronized (same 
style as the existing mutator check), the other holds the instance monitor 
while a second thread requests the 25th percentile and the main thread requests 
the 90th, then asserts the second thread still observes the 25th. 
SynchronizedDescriptiveStatisticsTest is now 22 tests, all green.


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