7132577: javax/management/monitor/MultiMonitorTest.java fails in JDK8-B22
authorasapre
Fri, 24 Feb 2017 14:59:39 +0530
changeset 44100 a5803b63fc79
parent 44006 5b8abcec4b80
child 44101 c1e41dd2cdf6
7132577: javax/management/monitor/MultiMonitorTest.java fails in JDK8-B22 Summary: Changed test’s own timeout mechanism to jtreg’s default timeout Reviewed-by: dholmes, egahlin Contributed-by: amit.sapre@oracle.com
jdk/test/javax/management/monitor/MultiMonitorTest.java
--- a/jdk/test/javax/management/monitor/MultiMonitorTest.java	Thu Feb 23 20:35:25 2017 +0530
+++ b/jdk/test/javax/management/monitor/MultiMonitorTest.java	Fri Feb 24 14:59:39 2017 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -116,6 +116,7 @@
         // A couple of granularity periods to detect bad behaviour
         Thread.sleep(2);
 
+        System.out.println("Checking for all listeners to be 0");
         if (!listenersAreAll(0, listeners)) {
             System.out.println("TEST FAILED: listeners not all 0");
             System.exit(1);
@@ -124,20 +125,18 @@
         for (int i = 0; i < 3; i++)
             proxies[i].start();
 
-        long startTime = System.currentTimeMillis();
-        while (!listenersAreAll(N, listeners)
-               && System.currentTimeMillis() < startTime + 5000)
-            Thread.sleep(1);
+        System.out.println("Waiting for listeners to all : " + N);
+        int iterations = 0;
+        while (!listenersAreAll(N, listeners)) {
+            Thread.sleep(500);
 
-        // More time for bad behaviour
-        Thread.sleep(1000);
-
-        if (!listenersAreAll(N, listeners)) {
-            System.out.print("TEST FAILED: listener counts wrong:");
-            for (int i = 0; i < listeners.length; i++)
-                System.out.print(" " + listeners[i].getCount());
-            System.out.println();
-            System.exit(1);
+            if (++iterations == 10) {
+               for (int i = 0; i < listeners.length; i++) {
+                   System.out.print(" " + listeners[i].getCount());
+               }
+               System.out.println();
+               iterations = 0;
+            }
         }
 
         for (int i = 0; i < 3; i++) {