RFR [6853696] (ref) ReferenceQueue.remove(timeout) may return null even if timeout has not expired

Ivan Gerasimov ivan.gerasimov at oracle.com
Tue Feb 25 14:32:38 UTC 2014


Thank you Mandy!

On 25.02.2014 2:11, Mandy Chung wrote:
> On 2/23/14 9:59 PM, Ivan Gerasimov wrote:
>> Hello!
>>
>> ReferenceQueue.remove(timeout) may return too early, i.e. before the 
>> specified timeout has elapsed.
>>
>> Would you please review the fix?
>> The change also includes a regression test, which can be used to 
>> demonstrate the issue.
>>
>> BUGURL: https://bugs.openjdk.java.net/browse/JDK-6853696
>> WEBREV: http://cr.openjdk.java.net/~igerasim/6853696/0/webrev/
>>
>
> I'll review the patch once you address the numerical overflow issue 
> Martin points out.  One minor comment - I suggest to use "start" and 
> "end" instead of "before" and "after".
>
I already operate on the difference (end-start), so the overflow should 
not happen.
Changed the names to start and end as you suggested.

> One comment on the test, line 61:  I think you want to check 
> thread.suspect expects to be true.  It may be simply keeping the 
> returned value of ReferenceQueue.remove call and check that in line 61 
> instead of having thread.suspect variable.
Done.

> line 76: why do you want to catch InterruptedException?  If 
> interrupted, should the test fail?
ReferenceQueue#remove() can throw InterruptedException, so I had to 
handle it.
In the new webrev I set the initial value of actual to TIMEOUT, so if 
the thread is interrupted the test will pass.

Please take a look at the updated webrev:
http://cr.openjdk.java.net/~igerasim/6853696/1/webrev/


Sincerely yours,
Ivan

>
> Mandy
>




More information about the core-libs-dev mailing list