JDK-6824583 : regtest TimeUnit/Basic.java fails intermittently on Windows - again
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-04-01
  • Updated: 2010-04-02
  • Resolved: 2009-04-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b54Fixed
Related Reports
Relates :  
Description
The testcase jdk/test/java/util/concurrent/TimeUnit/Basic.java expects MILLSECONDS.sleep(3) to sleep at least 3 when it could just return. Making the test for > 3 fail.

Comments
EVALUATION After some dicussion it was decided to just allow for the fact that the Thread.sleep(3) might be a Thread.sleep(0) due to the known Windows bug.
03-04-2009

EVALUATION http://hg.openjdk.java.net/jdk7/build/jdk/rev/70c53bc9a49d
03-04-2009

SUGGESTED FIX diff --git a/test/java/util/concurrent/TimeUnit/Basic.java b/test/java/util/concurrent/TimeUnit/Basic.java --- a/test/java/util/concurrent/TimeUnit/Basic.java +++ b/test/java/util/concurrent/TimeUnit/Basic.java @@ -59,11 +59,19 @@ public class Basic { equal(1000L, MILLISECONDS.toMicros(1)); equal(1000L, MICROSECONDS.toNanos(1)); - long t0 = System.nanoTime(); - MILLISECONDS.sleep(3); - long elapsedMillis = (System.nanoTime() - t0)/(1000L * 1000L); - System.out.printf("elapsed=%d%n", elapsedMillis); - check(elapsedMillis >= 3); + long elapsedMillis = 0; + int trys = 0; + while ( elapsedMillis < 3 && trys++ < 3 ) { + long t0 = System.nanoTime(); + MILLISECONDS.sleep(3); // See windows bug 6313903. + elapsedMillis = (System.nanoTime() - t0)/(1000L * 1000L); + System.out.printf("elapsed=%d%n", elapsedMillis); + if ( elapsedMillis < 3 ) { + System.out.printf("warning: MILLISECONDS.sleep(3) only slept for %d%n", + elapsedMillis); + } + } + check(elapsedMillis >= 3); check(elapsedMillis < 1000); //----------------------------------------------------------------
01-04-2009

EVALUATION May replicate the sleep(3), 3 times. Can't happen 3 times in a row, right? :^(
01-04-2009