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

Mandy Chung mandy.chung at oracle.com
Tue Feb 25 17:53:57 UTC 2014

On 2/25/14 6:32 AM, Ivan Gerasimov wrote:
>> 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.

Catching the InterruptedException would hide any unexpected issue as the 
test doesn't really expect to be interrupted. For example if the test is 
interrupted (kill -9), we should let the test to fail which is fine.  I 
suggest not to catch it.

line 61:  I think the test should be:
    if (thread.reference != null || thread.actual < TIMEOUT)

you may want to update the exception.  You could simply throw 
RuntimeException (just a minor point).

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

Looks okay.  I have a slight preference to keep the simple division to 
convert to millis rather than loading the enum TimeUnit class for this 


More information about the core-libs-dev mailing list