Parcourir la source

Merge -r 1355084:1355085 from trunk to branch. FIXES: HADOOP-8168

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1355086 13f79535-47bb-0310-9956-ffa450edef68
Alejandro Abdelnur il y a 13 ans
Parent
commit
b2324aa1fb

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -102,6 +102,9 @@ Release 2.0.1-alpha - UNRELEASED
     HADOOP-8512. AuthenticatedURL should reset the Token when the server returns 
     other than OK on authentication (tucu)
 
+    HADOOP-8168. empty-string owners or groups causes {{MissingFormatWidthException}} 
+    in o.a.h.fs.shell.Ls.ProcessPath() (ekoontz via tucu)
+
   BREAKDOWN OF HDFS-3042 SUBTASKS
 
     HADOOP-8220. ZKFailoverController doesn't handle failure to become active

+ 5 - 2
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java

@@ -134,8 +134,11 @@ class Ls extends FsCommand {
     StringBuilder fmt = new StringBuilder();
     fmt.append("%s%s "); // permission string
     fmt.append("%"  + maxRepl  + "s ");
-    fmt.append("%-" + maxOwner + "s ");
-    fmt.append("%-" + maxGroup + "s ");
+    // Do not use '%-0s' as a formatting conversion, since it will throw a
+    // a MissingFormatWidthException if it is used in String.format().
+    // http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html#intFlags
+    fmt.append((maxOwner > 0) ? "%-" + maxOwner + "s " : "%s");
+    fmt.append((maxGroup > 0) ? "%-" + maxGroup + "s " : "%s");
     fmt.append("%"  + maxLen   + "s ");
     fmt.append("%s %s"); // mod time & path
     lineFormat = fmt.toString();