United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6736316 TEST_BUG: Timeout value in java/util/concurrent/locks/Lock/FlakyMutex.java is insufficient
JDK-6736316 : TEST_BUG: Timeout value in java/util/concurrent/locks/Lock/FlakyMutex.java is insufficient

Details
Type:
Bug
Submit Date:
2008-08-12
Status:
Closed
Updated Date:
2013-12-17
Project Name:
JDK
Resolved Date:
2012-05-07
Component:
core-libs
OS:
linux,generic
Sub-Component:
java.util.concurrent
CPU:
arm,generic
Priority:
P5
Resolution:
Fixed
Affected Versions:
7,7u6
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:
Relates:

Sub Tasks

Description
Line 89 of 

   java/util/concurrent/locks/Lock/FlakyMutex.java

reads

   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.

                                    

Comments
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.
                                     
2011-11-21
EVALUATION

The 10 second timeout on termination of the worker threads is not
necessary, because the outer test harness already has timeouts built in.
                                     
2011-11-21
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 {
                                     
2011-11-21
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
                                     
2012-02-08



Hardware and Software, Engineered to Work Together