diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 11b62d981c6..997fd920c9d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -3870,9 +3870,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, while (it.hasNext()) { Block b = it.next(); BlockInfo blockInfo = blockManager.getStoredBlock(b); - BlockCollection bc = getBlockCollection(blockInfo); - if (bc.getStoragePolicyID() == lpPolicy.getId()) { - filesToDelete.add(bc); + if (blockInfo == null) { + LOG.info("Cannot find block info for block " + b); + } else { + BlockCollection bc = getBlockCollection(blockInfo); + if (bc.getStoragePolicyID() == lpPolicy.getId()) { + filesToDelete.add(bc); + } } }