From 7cca6440a5a7a96418952a259cb6c94d2f420c79 Mon Sep 17 00:00:00 2001 From: Dom Garguilo Date: Mon, 25 Nov 2024 11:56:10 -0500 Subject: [PATCH] Fix NPE caused by ExternalCompactions page in monitor --- .../main/java/org/apache/accumulo/monitor/Monitor.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java index 80dd69b8cd9..67fc46015d6 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java @@ -687,9 +687,10 @@ private static class ExternalCompactionsSnapshot { public final RunningCompactions runningCompactions; public final Map ecRunningMap; - private ExternalCompactionsSnapshot(Map ecRunningMap) { - this.ecRunningMap = Collections.unmodifiableMap(ecRunningMap); - this.runningCompactions = new RunningCompactions(ecRunningMap); + private ExternalCompactionsSnapshot(Optional> ecRunningMapOpt) { + this.ecRunningMap = + ecRunningMapOpt.map(Collections::unmodifiableMap).orElse(Collections.emptyMap()); + this.runningCompactions = new RunningCompactions(this.ecRunningMap); } } @@ -707,7 +708,7 @@ private ExternalCompactionsSnapshot computeExternalCompactionsSnapshot() { throw new IllegalStateException("Unable to get running compactions from " + ccHost, e); } - return new ExternalCompactionsSnapshot(running.getCompactions()); + return new ExternalCompactionsSnapshot(Optional.ofNullable(running.getCompactions())); } public RunningCompactions getRunnningCompactions() {