diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java index 75e5d9ad3d..f8d4ea40d4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java @@ -905,6 +905,11 @@ private ExtendedBlock getBlockToCopy(FsVolumeSpi.BlockIterator iter, while (!iter.atEnd() && item.getErrorCount() < getMaxError(item)) { try { ExtendedBlock block = iter.nextBlock(); + if(null == block){ + LOG.info("NextBlock call returned null.No valid block to copy. {}", + item.toJson()); + return block; + } if (block != null) { // A valid block is a finalized block, we iterate until we get