From b1d4af2492a973aa68bd9bba86a6f704ee0cc45e Mon Sep 17 00:00:00 2001 From: xuzq <15040255127@163.com> Date: Mon, 15 Aug 2022 20:57:27 +0800 Subject: [PATCH] HDFS-16704. Datanode return empty response instead of NPE for GetVolumeInfo during restarting (#4661). Contributed by ZanderXu. Signed-off-by: Ayush Saxena Signed-off-by: He Xiaoqiao --- .../org/apache/hadoop/hdfs/server/datanode/DataNode.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index d64502b6dd..9c77299e50 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -3628,7 +3628,10 @@ public String getBPServiceActorInfo() { */ @Override // DataNodeMXBean public String getVolumeInfo() { - Preconditions.checkNotNull(data, "Storage not yet initialized"); + if (data == null) { + LOG.debug("Storage not yet initialized."); + return ""; + } return JSON.toString(data.getVolumeInfoMap()); }