Просмотр исходного кода

HADOOP-9502. chmod/chown do not return error exit codes for some exceptions.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1471747 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 12 лет назад
Родитель
Сommit
2b29c43a9b

+ 3 - 0
CHANGES.txt

@@ -634,6 +634,9 @@ Release 1.2.0 - unreleased
     HADOOP-9458. Fix RPC.getProxy to ensure it uses retries for
     getProtocolVersion too. (szetszwo via acmurthy)
 
+    HADOOP-9502. chmod/chown do not return error exit codes for some exceptions.
+    (szetszwo)
+
 Release 1.1.2 - 2013.01.30
 
   INCOMPATIBLE CHANGES

+ 11 - 3
src/core/org/apache/hadoop/fs/FsShell.java

@@ -1235,8 +1235,9 @@ public class FsShell extends Configured implements Tool {
         errors++;
       }
       for(Path path : paths) {
+        FileStatus file = null;
         try {
-          FileStatus file = srcFs.getFileStatus(path);
+          file = srcFs.getFileStatus(path);
           if (file == null) {
             System.err.println(handler.getName() + 
                                ": could not get status for '" + path + "'");
@@ -1248,8 +1249,15 @@ public class FsShell extends Configured implements Tool {
           String msg = (e.getMessage() != null ? e.getLocalizedMessage() :
             (e.getCause().getMessage() != null ? 
                 e.getCause().getLocalizedMessage() : "null"));
-          System.err.println(handler.getName() + ": could not get status for '"
-                                        + path + "': " + msg.split("\n")[0]);
+          msg = msg.split("\n")[0];
+          if (file == null) {
+            //getFileStatus fails
+            msg = ": could not get status for '" + path + "': " + msg;
+          } else {
+            //other failure
+            msg = ": failed on '" + path + "': " + msg;
+          }
+          System.err.println(handler.getName() + msg);
           errors++;
         }
       }

+ 3 - 15
src/core/org/apache/hadoop/fs/FsShellPermissions.java

@@ -22,8 +22,8 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.hadoop.fs.FsShell.CmdHandler;
-import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.ChmodParser;
+import org.apache.hadoop.fs.permission.FsPermission;
 
 
 /**
@@ -65,13 +65,7 @@ class FsShellPermissions {
       int newperms = pp.applyNewPermission(file);
 
       if (file.getPermission().toShort() != newperms) {
-        try {
-          srcFs.setPermission(file.getPath(), 
-                                new FsPermission((short)newperms));
-        } catch (IOException e) {
-          System.err.println(getName() + ": changing permissions of '" + 
-                             file.getPath() + "':" + e.getMessage().split("\n")[0]);
-        }
+        srcFs.setPermission(file.getPath(), new FsPermission((short)newperms));
       }
     }
   }
@@ -124,13 +118,7 @@ class FsShellPermissions {
                         null : group;
 
       if (newOwner != null || newGroup != null) {
-        try {
-          srcFs.setOwner(file.getPath(), newOwner, newGroup);
-        } catch (IOException e) {
-          System.err.println(getName() + ": changing ownership of '" + 
-                             file.getPath() + "':" + e.getMessage().split("\n")[0]);
-
-        }
+        srcFs.setOwner(file.getPath(), newOwner, newGroup);
       }
     }
   }