[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    RFR 8129976: RunFinalizationTest.java times out frequently
From:       Jaroslav Bachorik <jaroslav.bachorik () oracle ! com>
Date:       2015-07-09 16:45:35
Message-ID: 559EA52F.7000507 () oracle ! com
[Download RAW message or body]

Please, review the following test change

Issue : https://bugs.openjdk.java.net/browse/JDK-8129976
Webrev: http://cr.openjdk.java.net/~jbachorik/8129976/webrev.00

The test, as it is now, most of the times does not test the desired 
functionality (that invoking GC.run_finalization DCMD actually runs 
finalization) because the preceding call to System.gc() will finalize 
the test object sooner. But without calling System.gc() it is non 
predictable when the test object will be eligible for finalization so we 
have to call System.gc().

In the rare occasions when System.gc() induced finalization does not 
finish before invoking GC.run_finalization the test deadlocks because 
its locking logic is flawed.

In order to make this test work I had to:
a\ Switch from '@run testng' to '@run main/othervm'
b\ Run the finalization testing code in shutdown handler - this seems to 
prevent the finalization happening prematurely after calling System.gc() 
while still making the test object eligible for finalization
c\ Switch from ReentrantLock to a Phaser for synchronization
d\ Make sure that the finalization is not carried out on the default 
"Finalizer" thread to rule out finalization due to System.gc()

After these changes the test seems to be rather stable (ran 1000 
iterations in a tight loop without single failure).

Thanks,

-JB-
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic