8170704: java/rmi/activation/Activatable/* tests fails intermittently with "output improperly annotated"
authormli
Tue, 06 Dec 2016 17:53:22 -0800
changeset 42436 83d5d07ae03a
parent 42435 349ac3a65124
child 42437 3224b6452c24
8170704: java/rmi/activation/Activatable/* tests fails intermittently with "output improperly annotated" Reviewed-by: dfuchs, rriggs
jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java
--- a/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java	Tue Dec 06 17:26:43 2016 -0800
+++ b/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java	Tue Dec 06 17:53:22 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -49,6 +49,7 @@
 public class CheckAnnotations
     extends Activatable implements MyRMI, Runnable
 {
+    private static final double TIME_FACTOR = TestLibrary.getTimeoutFactor();
 
     private static Object dummy = new Object();
     private static MyRMI myRMI = null;
@@ -111,9 +112,7 @@
             for (int i = 0; i < 3; i++) {
 
                 // object activated in annotation check via method call
-                if(!checkAnnotations(i-1)) {
-                    TestLibrary.bomb("Test failed: output improperly annotated.");
-                }
+                checkAnnotations(i-1);
 
                 /*
                  * Clean up object too.
@@ -143,24 +142,27 @@
      * check to make sure that the output from a spawned vm is
      * formatted/annotated properly.
      */
-    public static boolean checkAnnotations(int iteration)
+    public static void checkAnnotations(int iteration)
         throws IOException
     {
         try {
-            Thread.sleep(5000);
+            Thread.sleep((long)(5000 * TIME_FACTOR));
         } catch(Exception e) {
             System.err.println(e.getMessage());
         }
 
+        final String FAIL_MSG = "Test failed: output improperly annotated.";
+        final String OUT = "outABC";
+        final String ERR = "errXYZ";
         /**
          * cause the spawned vm to generate output that will
          * be checked for proper annotation.  printOut is
          * actually being called on an activated implementation.
          */
-        myRMI.printOut("out" + iteration);
-        myRMI.printErr("err" + iteration);
-        myRMI.printOut("out" + iteration);
-        myRMI.printErr("err" + iteration);
+        myRMI.printOut(OUT + iteration);
+        myRMI.printErr(ERR + iteration);
+        myRMI.printOut(OUT + iteration);
+        myRMI.printErr(ERR + iteration);
 
         /* we have to wait for output to filter down
          * from children so we can read it before we
@@ -174,7 +176,7 @@
             // have to give output from rmid time to trickle down to
             // this process
             try {
-                Thread.sleep(4000);
+                Thread.sleep((long)(4000 * TIME_FACTOR));
             } catch(InterruptedException e) {
             }
 
@@ -222,27 +224,24 @@
 
             if ((execErr == null)||(errTmp == null)||
                 (destErr == null)) {
-                return false;
+                TestLibrary.bomb(FAIL_MSG);
             }
             if ((execOut == null)||(outTmp == null)||
                 (destOut == null)) {
-                return false;
+                TestLibrary.bomb(FAIL_MSG);
             }
 
 
             // just make sure that last two strings are what we expect.
-            if (execOut.equals("ExecGroup-" + iteration)
-                && (new String(destOut.substring(0,4)).equals("out" +
+            if (!execOut.equals("ExecGroup-" + iteration)
+                || !(new String(destOut.substring(0,OUT.length()+1)).equals(OUT +
                                                               iteration))
-                && (execErr.equals("ExecGroup-"+iteration))
-                && (new String(destErr.substring(0,4)).equals("err" +
+                || !(execErr.equals("ExecGroup-"+iteration))
+                || !(new String(destErr.substring(0,ERR.length()+1)).equals(ERR +
                                                               iteration)) ) {
-                return true;
-            } else {
-                return false;
+                TestLibrary.bomb(FAIL_MSG);
             }
         }
-        return true;
     }
 
     // implementation of MyRMI, make this object activatable.