From 041e7a7dee4a17714f31952dc6364c77a65b1b73 Mon Sep 17 00:00:00 2001 From: Anu Engineer Date: Mon, 24 Jun 2019 15:34:11 -0700 Subject: [PATCH] HDFS-14598. Findbugs warning caused by HDFS-12487. Contributed by He Xiaoqiao. --- .../hdfs/server/datanode/DiskBalancer.java | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) 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 f8d4ea40d4..91833444d9 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 @@ -908,24 +908,17 @@ private ExtendedBlock getBlockToCopy(FsVolumeSpi.BlockIterator iter, 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(); }