United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7021010 (thread) TEST_BUG java/lang/Thread/ThreadStateTest.java fails intermittently
JDK-7021010 : (thread) TEST_BUG java/lang/Thread/ThreadStateTest.java fails intermittently

Details
Type:
Bug
Submit Date:
2011-02-21
Status:
Closed
Updated Date:
2013-06-26
Project Name:
JDK
Resolved Date:
2012-05-07
Component:
core-libs
OS:
solaris,linux,generic
Sub-Component:
java.lang
CPU:
arm,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
6u12,7,7u6
Fixed Versions:

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

Sub Tasks

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

see description.
                                     
2011-02-21
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
                                     
2011-06-23



Hardware and Software, Engineered to Work Together