JDK-6736316 : TEST_BUG: Timeout value in java/util/concurrent/locks/Lock/FlakyMutex.java is insufficient
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 7,7u6
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,linux
  • CPU: generic,arm
  • Submitted: 2008-08-12
  • Updated: 2013-12-17
  • Resolved: 2012-05-07
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.
7u21Fixed 8 b27Fixed
Related Reports
Relates :  
Line 89 of 



   check(es.awaitTermination(10, TimeUnit.SECONDS));

It turns out that on very slow machines with fastdebug builds this timeout is insufficient.

For instance, vm-v100-01.sfbay is a single CPU 650 MHz sparc. If I compile the test standalone and run it, I get this:

sd208054@vm-v100-01:~ $ /java/re/jdk/7/promoted/all/b32/binaries/solaris-sparcv9/fastdebug/bin/java -d64 FlakyMutex

java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Thread.java:1310)
        at FlakyMutex.fail(FlakyMutex.java:138)
        at FlakyMutex.check(FlakyMutex.java:141)
        at FlakyMutex.realMain(FlakyMutex.java:89)
        at FlakyMutex.main(FlakyMutex.java:146)

Passed = 75464, failed = 1

Exception in thread "main" java.lang.AssertionError: Some tests failed
        at FlakyMutex.main(FlakyMutex.java:148)

Doubling the timeout fixes the issue, at least for a machine this slow.

EVALUATION JDK8 Changeset: 7289599216fe Author: gadams Date: 2012-02-08 11:18 +0000 URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/7289599216fe 6736316: Timeout value in java/util/concurrent/locks/Lock/FlakyMutex.java is insufficient Reviewed-by: chegar, dholmes, alanb

SUGGESTED FIX diff --git a/test/java/util/concurrent/locks/Lock/FlakyMutex.java b/test/java/util/concurrent/locks/Lock/FlakyMutex.java --- a/test/java/util/concurrent/locks/Lock/FlakyMutex.java +++ b/test/java/util/concurrent/locks/Lock/FlakyMutex.java @@ -86,7 +86,16 @@ } catch (Throwable t) { unexpected(t); }}});} barrier.await(); es.shutdown(); - check(es.awaitTermination(10, TimeUnit.SECONDS)); + + boolean resultTermination = false; + for (int i = 0 ; i < 12 ; i ++) { + // Allow the service termination up to the test harness default + // of 120 seconds. Break out if the service finishes sooner. + if (resultTermination = es.awaitTermination(10, TimeUnit.SECONDS)) { + break; + } + } + check(resultTermination); } private static class FlakySync extends AbstractQueuedLongSynchronizer {

SUGGESTED FIX Remove the internal timeout and allow the threads to be reaped in their own time. The outer test harness will catch any failure to complete.

EVALUATION The 10 second timeout on termination of the worker threads is not necessary, because the outer test harness already has timeouts built in.