8257468: runtime/whitebox/TestWBDeflateIdleMonitors.java fails with Monitor should be deflated.: expected true to equal false

Reviewed-by: hseigel
This commit is contained in:
Daniel D. Daugherty 2020-12-23 22:02:09 +00:00
parent 9cd8e38ab8
commit 8b37c2c58f

View File

@ -40,6 +40,8 @@ import jdk.test.lib.process.OutputAnalyzer;
import sun.hotspot.WhiteBox;
public class TestWBDeflateIdleMonitors {
static final int N_DELAY = 1000; // delay between tries
static final int N_TRIES = 5; // number of times to try deflation
public static void main(String args[]) throws Exception {
ProcessBuilder pb = ProcessTools.createTestJvm(
@ -68,9 +70,22 @@ public class TestWBDeflateIdleMonitors {
Asserts.assertEQ(wb.isMonitorInflated(obj), true,
"Monitor should be inflated.");
}
boolean did_deflation = wb.deflateIdleMonitors();
Asserts.assertEQ(did_deflation, true,
"deflateIdleMonitors() should have worked.");
for (int cnt = 1; cnt <= N_TRIES; cnt++) {
System.out.println("Deflation try #" + cnt);
boolean did_deflation = wb.deflateIdleMonitors();
Asserts.assertEQ(did_deflation, true,
"deflateIdleMonitors() should have worked.");
if (!wb.isMonitorInflated(obj)) {
// Deflation worked so no more retries needed.
break;
}
try {
System.out.println("Deflation try #" + cnt + " failed. "
+ "Delaying before retry.");
Thread.sleep(N_DELAY);
} catch (InterruptedException ie) {
}
}
Asserts.assertEQ(wb.isMonitorInflated(obj), false,
"Monitor should be deflated.");
}