From 8b37c2c58f9d64cadc0321071826753b4ed2eae0 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Wed, 23 Dec 2020 22:02:09 +0000 Subject: [PATCH] 8257468: runtime/whitebox/TestWBDeflateIdleMonitors.java fails with Monitor should be deflated.: expected true to equal false Reviewed-by: hseigel --- .../whitebox/TestWBDeflateIdleMonitors.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/runtime/whitebox/TestWBDeflateIdleMonitors.java b/test/hotspot/jtreg/runtime/whitebox/TestWBDeflateIdleMonitors.java index ae8f02196c9..ed9a5b1bba3 100644 --- a/test/hotspot/jtreg/runtime/whitebox/TestWBDeflateIdleMonitors.java +++ b/test/hotspot/jtreg/runtime/whitebox/TestWBDeflateIdleMonitors.java @@ -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."); }