JDK-8151797 : java/lang/management/ThreadMXBean/ThreadLists.java : inconsistent results
  • Type: Bug
  • Component: core-svc
  • Sub-Component: java.lang.management
  • Affected Version: 9,10,11
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2016-03-14
  • Updated: 2018-04-30
  • Resolved: 2018-04-30
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 9
9Fixed
Related Reports
Relates :  
Relates :  
Description
----------messages:(3/121)----------
command: main ThreadLists
reason: Assumed action based on file name: run main ThreadLists 
elapsed time (seconds): 0.559
----------System.out:(4/127)----------
ThreadGroup: 5 active thread(s)
Thread: 5 stack trace(s) returned
ThreadMXBean: 6 live threads(s)
ThreadMXBean: 6 thread Id(s)
----------System.err:(13/721)----------
java.lang.RuntimeException: inconsistent results
	at ThreadLists.main(ThreadLists.java:67)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:520)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110)
	at java.lang.Thread.run(Thread.java:804)

Comments
From Initial Analysis, following simple fix for test case will make test case pass. Still investigating. public class ThreadLists { public static void main(String args[]) { + ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); + int threadCount = threadBean.getThreadCount(); + long[] threadIds = threadBean.getAllThreadIds(); + // get top-level thread group ThreadGroup top = Thread.currentThread().getThreadGroup(); ThreadGroup parent; @@ -48,10 +52,6 @@ Map<Thread, StackTraceElement[]> stackTraces = Thread.getAllStackTraces(); - ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); - int threadCount = threadBean.getThreadCount(); - long[] threadIds = threadBean.getAllThreadIds(); -
17-03-2016

Backing out the fix for JDK-8149925 makes the test pass again. I haven't looked at the changes in that fix to understand how it impacts this test.
16-03-2016

ILW = MHH (test failure, failing in the mainline nightly testing consistently since mar10, 2016, no workaround) = P2
16-03-2016