jmx-dev Codereview: JDK-8065764 javax/management/monitor/CounterMonitorTest.java hangs

Jaroslav Bachorik jaroslav.bachorik at oracle.com
Mon Dec 1 14:55:09 UTC 2014


On 12/01/2014 03:29 PM, Daniel Fuchs wrote:
>
>    55     // derived gange
>    56     private volatile int derivedGange = 1;
>
> Typo in both lines:  gange -> gauge
>
> -                 data = new Integer(values[i]);
> -                 echo(">>> Set data = " + data.intValue());
>
>
> It is strange that you no longer have to set the value to a
> different value.
>
> I don't understand how the test can succeed:
>
> first gauge:
> data.intValue() - 0 = data.intValue() = 0
>
> second gauge (and so on):
> data.intValue() - data.intValue() = 0
>
> how can that ever exceed the threshold of 2?

L27 in the new version reads - 'data = new Integer(data.intValue() + 
derivedGange);' where 'derivedGange' gets incremented in each pass 
before actually hitting L27. Therefore the sequence of values would be:
1. 2
2. 5
3. 9
4. 14
5. 20
6. 27
7. 35
8. 44
9. 54

Each time the increment is higher than the threshold.

-JB-

>
> I must have missed something.
>
> best regards
>
> -- daniel
>
>
> On 01/12/14 14:50, shanliang wrote:
>> Hi,
>> please review this test bug fix:
>>
>> webrev:
>> http://cr.openjdk.java.net/~sjiang/JDK-8065764/00/
>>
>> bug:
>> https://bugs.openjdk.java.net/browse/JDK-8065764
>>
>> The test tested the mode "difference", according to the Javadoc:
>>       If the counter difference mode is used, the value of the derived
>> gauge is calculated as the difference between the observed counter
>> values for two successive observations.
>>
>> The test set the first value and then waited 2 times of
>> granularityperiod at line 171, hoped that the monitor would get the
>> first observation during this waiting time, but the test could fail
>> because granularityperiod * 2 was not enough and the test did the second
>> set before the monitor did the first observation.
>>
>> It is easy to make the test timeout by commenting out the line 171.
>>
>> The proposed solution is to get informed when the monitor did
>> observation on calling:
>>     StdObservedObject.getNbObjects();
>>
>> Thanks,
>> Shanliang
>>
>>
>



More information about the jmx-dev mailing list