From 303c8dc9b6c853c0939ea9ba14388897cc258071 Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Fri, 26 May 2017 13:15:44 -0700 Subject: [PATCH] Fix NPE in LazyPersistFileScrubber. Contributed by Inigo Goiri. --- .../hadoop/hdfs/server/namenode/FSNamesystem.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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); + } } }