From 27468b2637776074e3baec81e311aadc349054ca Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Mon, 19 Oct 2020 12:00:03 +0200 Subject: [PATCH] Quick fix, catch null exceptions when getting metrics data. --- src/main/java/biz/nellemann/hmci/Insights.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/biz/nellemann/hmci/Insights.java b/src/main/java/biz/nellemann/hmci/Insights.java index 624ec76..bc472ac 100644 --- a/src/main/java/biz/nellemann/hmci/Insights.java +++ b/src/main/java/biz/nellemann/hmci/Insights.java @@ -152,12 +152,20 @@ class Insights { void writeMetricsForManagedSystems() { - systems.forEach((systemId, system) -> influxClient.writeManagedSystem(system)); + try { + systems.forEach((systemId, system) -> influxClient.writeManagedSystem(system)); + } catch (NullPointerException npe) { + log.warn("writeMetricsForManagedSystems() - NPE: " + npe.toString()); + } } void writeMetricsForLogicalPartitions() { - partitions.forEach((partitionId, partition) -> influxClient.writeLogicalPartition(partition)); + try { + partitions.forEach((partitionId, partition) -> influxClient.writeLogicalPartition(partition)); + } catch (NullPointerException npe) { + log.warn("writeMetricsForLogicalPartitions() - NPE: " + npe.toString()); + } } @@ -174,7 +182,6 @@ class Insights { Runtime.getRuntime().addShutdownHook(shutdownHook); do { - try { getMetricsForSystems(); getMetricsForPartitions();