diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java index 2b139b28277..23bfa95b4fa 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java @@ -132,7 +132,8 @@ public class Block implements Writable, Comparable { /** */ public String getBlockName() { - return BLOCK_FILE_PREFIX + String.valueOf(blockId); + return new StringBuilder().append(BLOCK_FILE_PREFIX) + .append(blockId).toString(); } /** @@ -160,7 +161,9 @@ public class Block implements Writable, Comparable { * @return the string representation of the block */ public static String toString(final Block b) { - return b.getBlockName() + "_" + b.getGenerationStamp(); + StringBuilder sb = new StringBuilder(); + b.appendStringTo(sb); + return sb.toString(); } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 3fee90d574f..76d5c24a5af 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -910,6 +910,9 @@ Release 2.9.0 - UNRELEASED HDFS-8477. describe dfs.ha.zkfc.port in hdfs-default.xml. (Kanaka Kumar Avvaru via wang) + HDFS-9350. Avoid creating temprorary strings in Block.toString() and + getBlockName() (Staffan Friberg via cmccabe) + OPTIMIZATIONS BUG FIXES