From 7c6426096a0021a3a739470273cf8ca3dfe64cab Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Wed, 6 Dec 2017 21:37:22 +0100 Subject: [PATCH] Patches a potentiell NullPointer when creating the BigDecimal from the BigInteger while writing the metric. --- .../extensions/rabbitmq/RabbitMQMonitoringTask.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/appdynamics/extensions/rabbitmq/RabbitMQMonitoringTask.java b/src/main/java/com/appdynamics/extensions/rabbitmq/RabbitMQMonitoringTask.java index a40508f..ff5145f 100644 --- a/src/main/java/com/appdynamics/extensions/rabbitmq/RabbitMQMonitoringTask.java +++ b/src/main/java/com/appdynamics/extensions/rabbitmq/RabbitMQMonitoringTask.java @@ -696,17 +696,16 @@ private List getQueues(ArrayNode queues, String nodeName) { public void printMetric(String metricName, BigInteger metricValue, String metricType) { - String value; - if (metricValue != null) { - value = metricValue.toString(); - } else { - value = "0"; + BigInteger metricValueNonNull = metricValue; + if (metricValue == null) { + metricValueNonNull = new BigInteger("0"); } + if (logger.isDebugEnabled()) { logger.debug("Sending [" - + "] metric = " + metricPrefix + metricName + " = " + value); + + "] metric = " + metricPrefix + metricName + " = " + metricValueNonNull.toString()); } - this.configuration.getMetricWriter().printMetric(metricPrefix + metricName, new BigDecimal(metricValue),metricType); + this.configuration.getMetricWriter().printMetric(metricPrefix + metricName, new BigDecimal(metricValueNonNull),metricType); }