Discussion:
ThreadInfoCompositeData.compositeType() broken in 11 and later
(too old to reply)
Sven Reimers
2018-10-21 17:50:44 UTC
Permalink
Hi,

seems with the change for

8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData
with missing JDK 6 attributes

ThreadInfoCompositeData.compositeType() was broken. It just returns

public static CompositeType compositeType() {
return ThreadInfoCompositeTypes.compositeTypes.get(0);
}

while ThreadInfoCompositeTypes.compositeTypes consists of

types.put(CURRENT, ctype);
types.put(5, initV5CompositeType(ctype));
types.put(6, initV6CompositeType(ctype));

so that compositeType just returns null, which further down the stack leads
to

java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at
org.netbeans.modules.sampler.SamplesOutputStream.toCompositeData(SamplesOutputStream.java:178)
at
org.netbeans.modules.sampler.SamplesOutputStream.access$400(SamplesOutputStream.java:44)
at
org.netbeans.modules.sampler.SamplesOutputStream$Sample.writeToStream(SamplesOutputStream.java:285)
at
org.netbeans.modules.sampler.SamplesOutputStream$Sample.access$300(SamplesOutputStream.java:253)
at
org.netbeans.modules.sampler.SamplesOutputStream.close(SamplesOutputStream.java:202)
at org.netbeans.modules.sampler.Sampler.stopSampling(Sampler.java:231)
at org.netbeans.modules.sampler.Sampler.stop(Sampler.java:207)
at
org.netbeans.core.ui.sampler.SelfSamplerAction$1.doInBackground(SelfSamplerAction.java:90)
at java.desktop/javax.swing.SwingWorker$1.call(SwingWorker.java:304)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.desktop/javax.swing.SwingWorker.run(SwingWorker.java:343)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:835)xx
Caused by: java.lang.IllegalArgumentException: Argument compositeType
cannot be null.
at
java.management/javax.management.openmbean.CompositeDataSupport.<init>(CompositeDataSupport.java:206)
at
java.management/javax.management.openmbean.CompositeDataSupport.<init>(CompositeDataSupport.java:118)
at
java.management/sun.management.ThreadInfoCompositeData.getCompositeData(ThreadInfoCompositeData.java:130)
at
java.management/sun.management.ThreadInfoCompositeData.toCompositeData(ThreadInfoCompositeData.java:72)
... 18 more

See also latest comments on NETBEANS-1359
<https://issues.apache.org/jira/browse/NETBEANS-1359?focusedCommentId=16658301&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16658301>
.

Thanks for investigating.

-Sven
Sven Reimers
2018-10-22 00:15:22 UTC
Permalink
Probable fix use Runtime.version().feature() instead of 0:

public static CompositeType compositeType() {
return
ThreadInfoCompositeTypes.compositeTypes.get(Runtime.version().feature());
}

Sven
Post by Sven Reimers
Hi,
seems with the change for
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData
with missing JDK 6 attributes
ThreadInfoCompositeData.compositeType() was broken. It just returns
public static CompositeType compositeType() {
return ThreadInfoCompositeTypes.compositeTypes.get(0);
}
while ThreadInfoCompositeTypes.compositeTypes consists of
types.put(CURRENT, ctype);
types.put(5, initV5CompositeType(ctype));
types.put(6, initV6CompositeType(ctype));
so that compositeType just returns null, which further down the stack
leads to
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at
org.netbeans.modules.sampler.SamplesOutputStream.toCompositeData(SamplesOutputStream.java:178)
at
org.netbeans.modules.sampler.SamplesOutputStream.access$400(SamplesOutputStream.java:44)
at
org.netbeans.modules.sampler.SamplesOutputStream$Sample.writeToStream(SamplesOutputStream.java:285)
at
org.netbeans.modules.sampler.SamplesOutputStream$Sample.access$300(SamplesOutputStream.java:253)
at
org.netbeans.modules.sampler.SamplesOutputStream.close(SamplesOutputStream.java:202)
at org.netbeans.modules.sampler.Sampler.stopSampling(Sampler.java:231)
at org.netbeans.modules.sampler.Sampler.stop(Sampler.java:207)
at
org.netbeans.core.ui.sampler.SelfSamplerAction$1.doInBackground(SelfSamplerAction.java:90)
at java.desktop/javax.swing.SwingWorker$1.call(SwingWorker.java:304)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.desktop/javax.swing.SwingWorker.run(SwingWorker.java:343)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:835)xx
Caused by: java.lang.IllegalArgumentException: Argument compositeType
cannot be null.
at
java.management/javax.management.openmbean.CompositeDataSupport.<init>(CompositeDataSupport.java:206)
at
java.management/javax.management.openmbean.CompositeDataSupport.<init>(CompositeDataSupport.java:118)
at
java.management/sun.management.ThreadInfoCompositeData.getCompositeData(ThreadInfoCompositeData.java:130)
at
java.management/sun.management.ThreadInfoCompositeData.toCompositeData(ThreadInfoCompositeData.java:72)
... 18 more
See also latest comments on NETBEANS-1359
<https://issues.apache.org/jira/browse/NETBEANS-1359?focusedCommentId=16658301&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16658301>
.
Thanks for investigating.
-Sven
--
Sven Reimers

* Senior Expert Software Architect
* Java Champion
* NetBeans Dream Team Member: http://dreamteam.netbeans.org
* Community Leader NetBeans: http://community.java.net/netbeans
Desktop Java:
http://community.java.net/javadesktop
* JUG Leader JUG Bodensee: http://www.jug-bodensee.de
* Duke's Choice Award Winner 2009

* XING: https://www.xing.com/profile/Sven_Reimers8
* LinkedIn: http://www.linkedin.com/in/svenreimers
Loading...