Please, review the following change Issue : https://bugs.openjdk.java.net/browse/JDK-8074041 Webrev: http://cr.openjdk.java.net/~jbachorik/8074041/webrev.00
This test fails very intermittently still and the failure is very hard to reproduce. Based on the symptoms the probable cause seems to be the asynchronous processing of a launched process stdout and stderr.
The test is using ProcessTools.startProcess(...) to start the target process and process its output (stdout/stderr) to mark the occurrence of the expected test. When the target process has finished the test will check the mark to assert the correctness. However, it may happen that the assertion happens in the time interval between the target process finishing (process.waitFor() returns) and the asynchronous stderr/stdout processors had the chance to dispatch the target process output to the processor checking for the occurrence of the expected test.
The proposed fix is to wrap the Process instance into a wrapper enhancing the waitFor() method with the wait for the stdout/stderr processor being finished before proceeding. I ran the test in a tight loop for 1000 times after applying this patch without any failure.
Thanks, -JB-