pthulasiram / jmxetric

Automatically exported from code.google.com/p/jmxetric
MIT License
0 stars 0 forks source link

If an attribute value is null, an exception is thrown as MBeanSampler attempts to publish it. #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Not a biggie, the main issue is that the resulting exception outputs its 
stacktrace to stderr, rather than to the configured logger.

What steps will reproduce the problem?
1. Add an attribute to jmxetric.xml which may have a null value - I 
discovered this by trying to publish values from 
"java.lang:type=GarbageCollector,name=PS MarkSweep" which is null until the 
first full GC initialises it
2.
3.

What is the expected output? What do you see instead?
I don't expect any output, but what I do see is a stacktrace for the 
NullPointerException. 

What version of the product are you using? On what operating system?
trunk, on ubuntu linux 2.6.31-20-generic

Please provide any additional information below.
I've made a small change to MBeanSampler containing 2 changes in 
MBeanAttribute.publish(). 

First off, I added a couple of null checks, so if the value isn't a 
Composite, it jmextric won't even attempt to publish it if its null. The 
second change was to output the stacktrace of any exception caught using 
the Logger, rather than with printStackTrace(). Patch attached.

Original issue reported on code.google.com by Sam.Tunn...@gmail.com on 23 Mar 2010 at 1:15

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Sam. Thanks for this - applied to trunk

Original comment by jasper...@gmail.com on 25 Mar 2010 at 7:49