diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java index a245f0c0060..a47939726ad 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java @@ -735,7 +735,7 @@ public class BlockPlacementPolicyDefault extends BlockPlacementPolicy { } Preconditions.checkState(excludedNodes.add(chosenNode), "chosenNode " + chosenNode + " is already in excludedNodes " + excludedNodes); - if (LOG.isDebugEnabled()) { + if (LOG.isDebugEnabled() && builder != null) { builder.append("\nNode ").append(NodeBase.getPath(chosenNode)) .append(" ["); } @@ -771,7 +771,7 @@ public class BlockPlacementPolicyDefault extends BlockPlacementPolicy { } } - if (LOG.isDebugEnabled()) { + if (LOG.isDebugEnabled() && builder != null) { builder.append("\n]"); }