diff --git a/nifi-commons/nifi-metrics/src/main/java/org/apache/nifi/metrics/jvm/JmxJvmMetrics.java b/nifi-commons/nifi-metrics/src/main/java/org/apache/nifi/metrics/jvm/JmxJvmMetrics.java index 55969fc137..ed2c3269f1 100644 --- a/nifi-commons/nifi-metrics/src/main/java/org/apache/nifi/metrics/jvm/JmxJvmMetrics.java +++ b/nifi-commons/nifi-metrics/src/main/java/org/apache/nifi/metrics/jvm/JmxJvmMetrics.java @@ -139,12 +139,14 @@ public class JmxJvmMetrics implements JvmMetrics { @Override public double heapUsage() { - return (Double) getMetric(MEMORY_HEAP_USAGE); + double usage = (Double) getMetric(MEMORY_HEAP_USAGE); + return usage < 0 ? -1.0 : usage; } @Override public double nonHeapUsage() { - return (Double) getMetric(MEMORY_NON_HEAP_USAGE); + double usage = (Double) getMetric(MEMORY_NON_HEAP_USAGE); + return usage < 0 ? -1.0 : usage; } @Override