From d35216ec6cfe39cc95ffe7bae4b57638e8cdd77b Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 30 Jan 2022 10:57:54 +0000 Subject: Fix NPE in DiskUsage util (#166) --- .../main/java/me/lucko/spark/common/monitor/disk/DiskUsage.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spark-common/src/main/java') diff --git a/spark-common/src/main/java/me/lucko/spark/common/monitor/disk/DiskUsage.java b/spark-common/src/main/java/me/lucko/spark/common/monitor/disk/DiskUsage.java index 4450fcd..7a4ada4 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/monitor/disk/DiskUsage.java +++ b/spark-common/src/main/java/me/lucko/spark/common/monitor/disk/DiskUsage.java @@ -44,6 +44,10 @@ public enum DiskUsage { } public static long getUsed() { + if (FILE_STORE == null) { + return 0; + } + try { long total = FILE_STORE.getTotalSpace(); return total - FILE_STORE.getUsableSpace(); @@ -53,6 +57,10 @@ public enum DiskUsage { } public static long getTotal() { + if (FILE_STORE == null) { + return 0; + } + try { return FILE_STORE.getTotalSpace(); } catch (IOException e) { -- cgit