From 02d66f66b31a166428221dfb7e0f100c011074cb Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 19 May 2016 22:24:00 +0300 Subject: [PATCH] 8148915: Intermittent failures of bug6400879.java Reviewed-by: amenkov --- jdk/test/ProblemList.txt | 2 -- .../sound/sampled/DirectAudio/bug6400879.java | 18 +++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 6e1cd7385d4..054c69ea66c 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -298,8 +298,6 @@ sun/security/x509/URICertStore/ExtensionsWithLDAP.java 8134577 generic- # jdk_sound -javax/sound/sampled/DirectAudio/bug6400879.java 8148915 linux-all - ############################################################################ # jdk_imageio diff --git a/jdk/test/javax/sound/sampled/DirectAudio/bug6400879.java b/jdk/test/javax/sound/sampled/DirectAudio/bug6400879.java index 770e774f609..375fb5727a2 100644 --- a/jdk/test/javax/sound/sampled/DirectAudio/bug6400879.java +++ b/jdk/test/javax/sound/sampled/DirectAudio/bug6400879.java @@ -26,10 +26,11 @@ * @bug 6400879 7100140 * @summary Tests that Start/Stop sequence doesn't hang * @author Alexey Menkov - * @run main bug6400879 - * @key intermittent + * @run main/othervm bug6400879 */ +import java.util.concurrent.TimeUnit; + import javax.sound.sampled.*; public class bug6400879 extends Thread { @@ -50,16 +51,16 @@ public class bug6400879 extends Thread { long prevTime = currentTimeMillis(); while (pThis.isAlive()) { if (pThis.loopCounter == prevLoop) { - if (currentTimeMillis() - prevTime > BLOCK_TIMEOUT) { - // block! - log("Test FAILED."); - throw new RuntimeException("Test FAILED: thread has been blocked!"); + long delay = currentTimeMillis() - prevTime; + if (delay > BLOCK_TIMEOUT) { + // blocked? + log("The test is slow, delay = " + delay); } } else { prevLoop = pThis.loopCounter; prevTime = currentTimeMillis(); } - delay(500); // sleep for 0.5 sec + delay(1000); // sleep for 1 sec } log("Test sucessfully passed."); } @@ -111,8 +112,7 @@ public class bug6400879 extends Thread { // helper routines static long startTime = currentTimeMillis(); static long currentTimeMillis() { - //return System.nanoTime() / 1000000L; - return System.currentTimeMillis(); + return TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); } static void log(String s) { long time = currentTimeMillis() - startTime;