8000817: Reinstate accidentally removed sleep() from ProcessBuilder/Basic.java
authorrobm
Mon, 15 Oct 2012 03:26:11 +0100
changeset 14183 26e97eede839
parent 14182 3041082abb40
child 14184 5553422ece67
8000817: Reinstate accidentally removed sleep() from ProcessBuilder/Basic.java Reviewed-by: alanb, martin
jdk/test/java/lang/ProcessBuilder/Basic.java
--- a/jdk/test/java/lang/ProcessBuilder/Basic.java	Sun Oct 14 22:58:59 2012 +0100
+++ b/jdk/test/java/lang/ProcessBuilder/Basic.java	Mon Oct 15 03:26:11 2012 +0100
@@ -41,6 +41,7 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.security.*;
+import sun.misc.Unsafe;
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
 import static java.lang.System.getenv;
@@ -1960,6 +1961,7 @@
 
                 thread.start();
                 latch.await();
+                Thread.sleep(10);
 
                 String os = System.getProperty("os.name");
                 if (os.equalsIgnoreCase("Solaris") ||
@@ -1984,6 +1986,15 @@
                     while (useCountField.getInt(deferred) <= 0) {
                         Thread.yield();
                     }
+                } else if (s instanceof BufferedInputStream) {
+                    Field f = Unsafe.class.getDeclaredField("theUnsafe");
+                    f.setAccessible(true);
+                    Unsafe unsafe = (Unsafe)f.get(null);
+
+                    while (unsafe.tryMonitorEnter(s)) {
+                        unsafe.monitorExit(s);
+                        Thread.sleep(1);
+                    }
                 }
                 p.destroy();
                 thread.join();