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 e41bb8fd94e..efd20c36639 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 @@ -3895,9 +3895,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); + } } }