Skip to content

Commit dcd05a3

Browse files
Fix NullPointerException during scrape (#892)
Signed-off-by: Simon Greatrix <simon.greatrix@setl.io>
1 parent 89275ac commit dcd05a3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

collector/src/main/java/io/prometheus/jmx/JmxScraper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ private void scrapeBean(MBeanServerConnection beanConn, ObjectName mBeanName) {
213213
}
214214

215215
for (Object object : attributes) {
216+
// The contents of an AttributeList should all be Attribute instances, but we'll verify that.
216217
if (object instanceof Attribute) {
217218
Attribute attribute = (Attribute) object;
218219
String attributeName = attribute.getName();
@@ -241,6 +242,11 @@ private void scrapeBean(MBeanServerConnection beanConn, ObjectName mBeanName) {
241242
mBeanAttributeInfo.getType(),
242243
mBeanAttributeInfo.getDescription(),
243244
attribute.getValue());
245+
} else if (object == null) {
246+
LOGGER.log(
247+
FINE,
248+
"%s object is NULL, not an instance javax.management.Attribute, skipping",
249+
mBeanName);
244250
} else {
245251
LOGGER.log(
246252
FINE,

0 commit comments

Comments
 (0)