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 ee64d8de41a..8d5660e5ed1 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 @@ -906,24 +906,17 @@ public class DiskBalancer { if(null == block){ LOG.info("NextBlock call returned null.No valid block to copy. {}", item.toJson()); + return null; + } + // A valid block is a finalized block, we iterate until we get + // finalized blocks + if (!this.dataset.isValidBlock(block)) { + continue; + } + // We don't look for the best, we just do first fit + if (isLessThanNeeded(block.getNumBytes(), item)) { return block; } - - if (block != null) { - // A valid block is a finalized block, we iterate until we get - // finalized blocks - if (!this.dataset.isValidBlock(block)) { - continue; - } - - // We don't look for the best, we just do first fit - if (isLessThanNeeded(block.getNumBytes(), item)) { - return block; - } - } else { - LOG.info("There are no blocks in the blockPool {}", iter.getBlockPoolId()); - } - } catch (IOException e) { item.incErrorCount(); }