6512493: TEST_BUG: unexpected LockInfo failure in LockedSynchronizers.java
authormchung
Tue, 26 May 2009 18:07:14 -0700
changeset 2933 08ea3ecb912c
parent 2932 e27a79fe5e7a
child 2934 7b3a71a2fc3c
6512493: TEST_BUG: unexpected LockInfo failure in LockedSynchronizers.java Summary: Retry a few times to check thread status before reporting failure Reviewed-by: swamyv
jdk/test/java/lang/management/ThreadMXBean/LockingThread.java
jdk/test/java/lang/management/ThreadMXBean/MonitorDeadlock.java
--- a/jdk/test/java/lang/management/ThreadMXBean/LockingThread.java	Tue May 26 18:02:44 2009 -0700
+++ b/jdk/test/java/lang/management/ThreadMXBean/LockingThread.java	Tue May 26 18:07:14 2009 -0700
@@ -66,6 +66,8 @@
                throw new RuntimeException(e);
            }
         }
+        Utils.waitForBlockWaitingState(t1);
+        Utils.waitForBlockWaitingState(t2);
     }
     static long[] getThreadIds() {
         return new long[] {t1.getId(), t2.getId()};
--- a/jdk/test/java/lang/management/ThreadMXBean/MonitorDeadlock.java	Tue May 26 18:02:44 2009 -0700
+++ b/jdk/test/java/lang/management/ThreadMXBean/MonitorDeadlock.java	Tue May 26 18:07:14 2009 -0700
@@ -83,11 +83,24 @@
 
     void waitUntilDeadlock() {
         barr.await();
-        // sleep a little while to wait until threads are blocked.
-        try {
-            Thread.sleep(100);
-        } catch (InterruptedException e) {
-            // ignore
+
+        for (int i=0; i < 100; i++) {
+            // sleep a little while to wait until threads are blocked.
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignore
+            }
+            boolean retry = false;
+            for (Thread t: dThreads) {
+                if (t.getState() == Thread.State.RUNNABLE) {
+                    retry = true;
+                    break;
+                }
+            }
+            if (!retry) {
+                break;
+            }
         }
     }