浏览代码

Fix NPE in LazyPersistFileScrubber. Contributed by Inigo Goiri.

(cherry picked from commit 303c8dc9b6c853c0939ea9ba14388897cc258071)

Conflicts:
	hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Inigo Goiri 8 年之前
父节点
当前提交
948d0ac72d

+ 2 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -326,6 +326,8 @@ Release 2.7.4 - UNRELEASED
     HDFS-11445. FSCK shows overall health stauts as corrupt even one replica is corrupt. 
     (Brahma Reddy Battula)
 
+    Fix NPE in LazyPersistFileScrubber. (Inigo Goiri via shv)
+
 Release 2.7.3 - 2016-08-25
 
   INCOMPATIBLE CHANGES

+ 7 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

@@ -4682,9 +4682,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
         while (it.hasNext()) {
           Block b = it.next();
           BlockInfoContiguous blockInfo = blockManager.getStoredBlock(b);
-          if (blockInfo.getBlockCollection().getStoragePolicyID()
-              == lpPolicy.getId()) {
-            filesToDelete.add(blockInfo.getBlockCollection());
+          if (blockInfo == null) {
+            LOG.info("Cannot find block info for block " + b);
+          } else {
+            if (blockInfo.getBlockCollection().getStoragePolicyID()
+                == lpPolicy.getId()) {
+              filesToDelete.add(blockInfo.getBlockCollection());
+            }
           }
         }