diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java index 2aab5b79234c8621222b75e43426987c804e30aa..639a200955974ef36ff8cd8313a912ccfe38eb2f 100644 --- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java +++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java @@ -200,14 +200,20 @@ public class UtilAll { } public static double getDiskPartitionSpaceUsedPercent(final String path) { - if (null == path || path.isEmpty()) + if (null == path || path.isEmpty()) { + log.error("Error when measuring disk space usage, path is null or empty, path : {}", path); return -1; + } + try { File file = new File(path); - if (!file.exists()) + if (!file.exists()) { + log.error("Error when measuring disk space usage, file doesn't exist on this path: {}", path); return -1; + } + long totalSpace = file.getTotalSpace(); @@ -218,6 +224,7 @@ public class UtilAll { return usedSpace / (double) totalSpace; } } catch (Exception e) { + log.error("Error when measuring disk space usage, got exception: :", e); return -1; }