Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEVERE: JMX scrape failed: java.lang.ClassCastException: javax.management.openmbean.TabularDataSupport cannot be cast to javax.management.Attribute #542

Conversation

nbonavia
Copy link
Contributor

@nbonavia nbonavia commented Oct 8, 2020

Added a sanitary check to the JMX Scraper so that it will skip Attributes processing that are not javax.management.Attribute types. This is an issue present in Apache Ignite, when there are some Attributes that are of type javax.management.openmbean.TabularDataSupport

Signed-off-by: Neville Bonavia neville.bonavia@gig.com

The error log in such a situation is: -
Oct 08, 2020 1:28:28 PM io.prometheus.jmx.JmxCollector collect
SEVERE: JMX scrape failed: java.lang.ClassCastException: javax.management.openmbean.TabularDataSupport cannot be cast to javax.management.Attribute
at io.prometheus.jmx.JmxScraper.scrapeBean(JmxScraper.java:163)
at io.prometheus.jmx.JmxScraper.doScrape(JmxScraper.java:117)
at io.prometheus.jmx.JmxCollector.collect(JmxCollector.java:542)
at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:190)
at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:223)
at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:144)
at io.prometheus.client.exporter.common.TextFormat.write004(TextFormat.java:22)
at io.prometheus.client.exporter.HTTPServer$HTTPMetricHandler.handle(HTTPServer.java:68)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

…utes processing that are not javax.management.Attribute types. This is an issue present in Apache Ignite, when there are some Attributes that are of type javax.management.openmbean.TabularDataSupport

Signed-off-by: Neville Bonavia <neville.bonavia@gig.com>
@brian-brazil
Copy link
Contributor

Thanks!

Has someone filed a bug against Ignite?

@bjorndemicoli
Copy link

i was actually tired of crying on this issue, neville just saved my life.

@sdarlington
Copy link

Has anyone successfully used this patch? In my use, I'm getting an exception on line 160 (in attributes.asList()) and needed to put an extra try/catch block around the for loop (sdarlington@8cfc075). Am I missing something?

@azsane
Copy link

azsane commented Jan 22, 2021

Dig into source code in openjdk8
AttributeList.java

if non Attribute type obj is added to AttributeList,the tainted became true
When asList is invoked,type check will performed at adding
Since typeSafe flag is on , exception will be thrown if non Attribute type obj is encounted

So at least in openjdk implementation, returned normally asList() doesn't need any Class Type check
but in abnormal case,you can only catch exception thrown by asList

The fix in line 160 should change to
for (Object attributeObj : attributes) {
AttributeList extends ArrayList and can be iterated directrly

@hholierhoek
Copy link

Agreed, this doesn't work. I get the same exception down in asList().

@piotrrybicki
Copy link

piotrrybicki commented Mar 15, 2021

for ignite 2.9.1, blacklisting views in jmx_exporter config allows other metrics to be exposed :

blacklistObjectNames: ["org.apache:clsLdr=*,group=views,*"]

@xudesheng
Copy link

Dig into source code in openjdk8
AttributeList.java

if non Attribute type obj is added to AttributeList,the tainted became true
When asList is invoked,type check will performed at adding
Since typeSafe flag is on , exception will be thrown if non Attribute type obj is encounted

So at least in openjdk implementation, returned normally asList() doesn't need any Class Type check
but in abnormal case,you can only catch exception thrown by asList

The fix in line 160 should change to
for (Object attributeObj : attributes) {
AttributeList extends ArrayList and can be iterated directrly

agreed and tested.

Can anyone create a new pull request to fix this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants