JDK-5080203 : TEST_BUG: ThreadStateTest fails intermittently.
  • Type: Bug
  • Component: core-svc
  • Sub-Component: java.lang.management
  • Affected Version: 5.0
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-07-29
  • Updated: 2012-10-01
  • Resolved: 2009-06-22
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 b62Fixed
Related Reports
Relates :  
Description
Following test fails intermittently. 

java/lang/management/ThreadMXBean/ThreadStateTest.java

Intermittently it returns TIMED_WAIT instead of RUNNING because
of race condition in test case. When the testing thread is
querying for target thread state and that thread could be
in wait or running. It is hard to predict when the thread
would be in running. So we need to come up with better
logic to test this thread state.
Some times it also fails with TIMED_WAITING when it is expecting WAITING
thread state.

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/tl/jdk/rev/fba2425da9b1
27-05-2009

SUGGESTED FIX Here is suggested fix for this problem. if (state != expected) { int retryCount=0; while (ti.getThreadState() != expected) { if (retryCount >= 500) { // Print target thread stack trace. StackTraceElement st[] = t.getStackTrace(); for (int i =0 ; i<st.length; i++) { System.out.println(st[i]); } throw new RuntimeException(t.getName() + " expected to have " + expected + " but got " + state); } goSleep(100); }
19-10-2006

EVALUATION In the ThreadStateTest.java program when thread is expecting WAITING state the check thread state gets the TIMED_WAIT because the target thread is in thread.sleep() when running inside thrsync.signal() at line 288. So this is a testcase bug.
19-10-2006

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon
01-09-2004

EVALUATION Need to fix the testing of running thread state.
01-09-2004