Details
-
Bug
-
Status: Resolved
-
Low
-
Resolution: Fixed
-
None
-
None
-
Low
Description
On method getBuckets(), under concurrent use of an instance, the value of a "buckets" variable element might change between its access on the 1st for cycle and its access on the 2nd, when it is reset to 0. This means that, if one collects metrics by repeatedly calling estHist.getBuckets(true), (e.g.: to sum its values) it will miss counting some values added to "buckets" entries between that 1st and 2nd access.
On method mean(), if the i-th entry of "buckets" changes value between the 1st and 2nd access inside the for cycle, than the "elements" and "sum" accumulators are not working with the same values for that entry. It is more precise (and faster) to use a local variable to read the value just once.
Not an error but a semantic improvement: at my initial read of this class, I thought the "buckets" and "bucketOffsets" fields could change length. Such perception can be avoided by making the "bucketOffsets" field final.