diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index 2de8aac7dba..207ac5b67c3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -1210,16 +1210,19 @@ public class BlockManager implements BlockStatsMXBean { if (!isPopulatingReplQueues()) { return; } - StringBuilder datanodes = new StringBuilder(); + StringBuilder datanodes = blockLog.isDebugEnabled() + ? new StringBuilder() : null; for (DatanodeStorageInfo storage : blocksMap.getStorages(b)) { if (storage.getState() != State.NORMAL) { continue; } final DatanodeDescriptor node = storage.getDatanodeDescriptor(); invalidateBlocks.add(b, node, false); - datanodes.append(node).append(" "); + if (datanodes != null) { + datanodes.append(node).append(" "); + } } - if (datanodes.length() != 0) { + if (datanodes != null & datanodes.length() != 0) { blockLog.debug("BLOCK* addToInvalidates: {} {}", b, datanodes); } }