JDK-7021010 : (thread) TEST_BUG java/lang/Thread/ThreadStateTest.java fails intermittently
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6u12,7,7u6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,linux,solaris
  • CPU: generic,arm
  • Submitted: 2011-02-21
  • Updated: 2013-08-14
  • 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.
JDK 7 JDK 8
7u40Fixed 8 b01Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
java/lang/Thread/ThreadStateTest.java can fail with when checkThreadState finds an unexpected state.

Exception in thread "main" java.lang.RuntimeException: MyThread expected to have TERMINATED but got RUNNABLE
	at ThreadStateTest.checkThreadState(ThreadStateTest.java:119)
	at ThreadStateTest.main(ThreadStateTest.java:96)

There are races between the thread being put in a specific state and the thread testing for that state. The failure is not see that often, but is easily reproducible with -Xcomp, as this changes the timing of the execution of the test, see CR 6725455.

The test should be updated in a similar fashion to java/lang/management/ThreadMXBean/ThreadStateTest.java, see CR 5080203. That is, retry the thread state check a number of times before failing.

Comments
EVALUATION The test has been updated to use java.util.concurrent.Phaser as the synchronization barrier between the two threads, and also to retry the check for the expected myThread state. If you're interested you can see discussion of these changes on core-lib-dev: http://mail.openjdk.java.net/pipermail/core-libs-dev/2011-June/007028.html JDK8 changeset: Changeset: ae7211979179 Author: chegar Date: 2011-06-23 13:15 +0100 URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/ae7211979179 7021010: java/lang/Thread/ThreadStateTest.java fails intermittently Reviewed-by: dholmes, alanb, mchung ! test/ProblemList.txt ! test/java/lang/Thread/ThreadStateTest.java
23-06-2011

EVALUATION see description.
21-02-2011