From 1fbb662c7092d08a540acff7e92715693412e486 Mon Sep 17 00:00:00 2001 From: Mingliang Liu Date: Thu, 31 Aug 2017 22:36:56 -0700 Subject: [PATCH] HDFS-12363. Possible NPE in BlockManager$StorageInfoDefragmenter#scanAndCompactStorages. Contributed by Xiao Chen --- .../hadoop/hdfs/server/blockmanagement/BlockManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index 6129db8a5a0..e83cbc6ef4a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -4487,8 +4487,12 @@ public class BlockManager implements BlockStatsMXBean { for (int i = 0; i < datanodesAndStorages.size(); i += 2) { namesystem.writeLock(); try { - DatanodeStorageInfo storage = datanodeManager. - getDatanode(datanodesAndStorages.get(i)). + final DatanodeDescriptor dn = datanodeManager. + getDatanode(datanodesAndStorages.get(i)); + if (dn == null) { + continue; + } + final DatanodeStorageInfo storage = dn. getStorageInfo(datanodesAndStorages.get(i + 1)); if (storage != null) { boolean aborted =