RFR: 8066952 [TEST-BUG] javax/management/monitor/CounterMonitorTest.java hangs
Daniel Fuchs
daniel.fuchs at oracle.com
Fri Dec 12 13:05:32 UTC 2014
On 12/12/14 13:44, shanliang wrote:
> Hi,
>
> As Daniel said: "I think that what happens here is that the
> StdObservedObject.getNbObjects() getter unblocks the main thread before
> returning the value to the monitor. This makes it possible to have a
> race condition where the next setNbObjects called by the main thread can
> then occur before the result of StdObservedObject.getNbObjects() is
> taken into account - and even before the
> StdObservedObject.getNbObjects() actually returns. So
> StdObservedObject.getNbObjects() may return a value different than the
> one which was observed. In our case, it would return 3 (the newer value)
> instead of 0 (the value that was observed). "
>
> The suggested fix is to return "observedValue" instead of "count", in
> this way we check also that the monitor never starts next observation
> before the current one finishes.
Looks good Shanliang!
-- daniel
>
> bug: https://bugs.openjdk.java.net/browse/JDK-8066952
> webrev: http://cr.openjdk.java.net/~sjiang/JDK-8066952/00/
>
> Thanks,
> Shanliang
More information about the serviceability-dev
mailing list