diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 697bdee161e..700a8da2086 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -278,6 +278,9 @@ Release 2.5.0 - UNRELEASED HDFS-3087. Decomissioning on NN restart can complete without blocks being replicated. (Rushabh S Shah via kihwal) + HDFS-6162. Format strings should use platform independent line separator. + (suresh) + Release 2.4.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java index 2d42139d7d8..7396dedc545 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java @@ -801,7 +801,7 @@ implements ByteBufferReadable, CanSetDropBehind, CanSetReadahead, // got a EOS from reader though we expect more data on it. throw new IOException("Unexpected EOS from the reader"); } - if (dfsClient.stats != null && result != -1) { + if (dfsClient.stats != null) { dfsClient.stats.incrementBytesRead(result); } return result; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index e015514a82e..d0527ad8701 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -4997,7 +4997,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats, if (blockSafe < blockThreshold) { msg += String.format( "The reported blocks %d needs additional %d" - + " blocks to reach the threshold %.4f of total blocks %d.\n", + + " blocks to reach the threshold %.4f of total blocks %d.%n", blockSafe, (blockThreshold - blockSafe) + 1, threshold, blockTotal); thresholdsMet = false; } else { @@ -5007,7 +5007,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats, if (numLive < datanodeThreshold) { msg += String.format( "The number of live datanodes %d needs an additional %d live " - + "datanodes to reach the minimum number %d.\n", + + "datanodes to reach the minimum number %d.%n", numLive, (datanodeThreshold - numLive), datanodeThreshold); thresholdsMet = false; } else { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java index 7ee148cc236..b7ac968dede 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java @@ -583,7 +583,7 @@ public class CacheAdmin extends Configured implements Tool { tableListing.addRow(row.toArray(new String[0])); numEntries++; } - System.out.print(String.format("Found %d entr%s\n", + System.out.print(String.format("Found %d entr%s%n", numEntries, numEntries == 1 ? "y" : "ies")); if (numEntries > 0) { System.out.print(tableListing); @@ -968,7 +968,7 @@ public class CacheAdmin extends Configured implements Tool { System.err.println(prettifyException(e)); return 2; } - System.out.print(String.format("Found %d result%s.\n", numResults, + System.out.print(String.format("Found %d result%s.%n", numResults, (numResults == 1 ? "" : "s"))); if (numResults > 0) { System.out.print(listing); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/LsrPBImage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/LsrPBImage.java index d80fcf1e94c..7ea8ba44fc1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/LsrPBImage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/LsrPBImage.java @@ -159,7 +159,7 @@ final class LsrPBImage { INodeFile f = inode.getFile(); PermissionStatus p = FSImageFormatPBINode.Loader.loadPermission( f.getPermission(), stringTable); - out.print(String.format("-%s %2s %8s %10s %10s %10d %s%s\n", p + out.print(String.format("-%s %2s %8s %10s %10s %10d %s%s%n", p .getPermission().toString(), f.getReplication(), p.getUserName(), p .getGroupName(), f.getModificationTime(), getFileSize(f), parent, inode.getName().toStringUtf8())); @@ -169,7 +169,7 @@ final class LsrPBImage { INodeDirectory d = inode.getDirectory(); PermissionStatus p = FSImageFormatPBINode.Loader.loadPermission( d.getPermission(), stringTable); - out.print(String.format("d%s - %8s %10s %10s %10d %s%s\n", p + out.print(String.format("d%s - %8s %10s %10s %10d %s%s%n", p .getPermission().toString(), p.getUserName(), p.getGroupName(), d .getModificationTime(), 0, parent, inode.getName().toStringUtf8())); } @@ -178,7 +178,7 @@ final class LsrPBImage { INodeSymlink d = inode.getSymlink(); PermissionStatus p = FSImageFormatPBINode.Loader.loadPermission( d.getPermission(), stringTable); - out.print(String.format("-%s - %8s %10s %10s %10d %s%s -> %s\n", p + out.print(String.format("-%s - %8s %10s %10s %10d %s%s -> %s%n", p .getPermission().toString(), p.getUserName(), p.getGroupName(), d .getModificationTime(), 0, parent, inode.getName().toStringUtf8(), d.getTarget().toStringUtf8()));