Skip to content

Commit

Permalink
Fix NullPointerException during scrape (#892)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Greatrix <simon.greatrix@setl.io>
  • Loading branch information
simon-greatrix authored Nov 15, 2023
1 parent 89275ac commit dcd05a3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions collector/src/main/java/io/prometheus/jmx/JmxScraper.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ private void scrapeBean(MBeanServerConnection beanConn, ObjectName mBeanName) {
}

for (Object object : attributes) {
// The contents of an AttributeList should all be Attribute instances, but we'll verify that.
if (object instanceof Attribute) {
Attribute attribute = (Attribute) object;
String attributeName = attribute.getName();
Expand Down Expand Up @@ -241,6 +242,11 @@ private void scrapeBean(MBeanServerConnection beanConn, ObjectName mBeanName) {
mBeanAttributeInfo.getType(),
mBeanAttributeInfo.getDescription(),
attribute.getValue());
} else if (object == null) {
LOGGER.log(
FINE,
"%s object is NULL, not an instance javax.management.Attribute, skipping",
mBeanName);
} else {
LOGGER.log(
FINE,
Expand Down

0 comments on commit dcd05a3

Please sign in to comment.