Repository: hadoop
Updated Branches:
  refs/heads/trunk 95d5227c7 -> b21dffb1f


HDFS-9451. Clean up depreated umasks and related unit tests. Contributed by 
Wei-Chiu Chuang.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b21dffb1
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b21dffb1
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b21dffb1

Branch: refs/heads/trunk
Commit: b21dffb1fec376784810af89cfc9cc05e5f781ce
Parents: 95d5227
Author: Haohui Mai <whe...@apache.org>
Authored: Wed Nov 25 12:47:24 2015 -0800
Committer: Haohui Mai <whe...@apache.org>
Committed: Wed Nov 25 12:47:24 2015 -0800

----------------------------------------------------------------------
 .../hadoop/fs/permission/FsPermission.java      |  7 ------
 .../hadoop/fs/permission/TestFsPermission.java  | 10 ---------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 +++
 .../apache/hadoop/security/TestPermission.java  | 23 +++++---------------
 4 files changed, 8 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b21dffb1/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java
----------------------------------------------------------------------
diff --git 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java
 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java
index d4adbb5..b535fd6 100644
--- 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java
+++ 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java
@@ -215,9 +215,6 @@ public class FsPermission implements Writable {
         otheraction.and(umask.otheraction.not()));
   }
 
-  /** umask property label deprecated key and code in getUMask method
-   *  to accommodate it may be removed in version .23 */
-  public static final String DEPRECATED_UMASK_LABEL = "dfs.umask"; 
   public static final String UMASK_LABEL = 
                   CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY;
   public static final int DEFAULT_UMASK = 
@@ -236,8 +233,6 @@ public class FsPermission implements Writable {
    * '-' sets bits in the mask.
    * 
    * Octal umask, the specified bits are set in the file mode creation mask.
-   * 
-   * {@code DEPRECATED_UMASK_LABEL} config param has umask value set to 
decimal.
    */
   public static FsPermission getUMask(Configuration conf) {
     int umask = DEFAULT_UMASK;
@@ -246,7 +241,6 @@ public class FsPermission implements Writable {
     // If the deprecated key is not present then check for the new key
     if(conf != null) {
       String confUmask = conf.get(UMASK_LABEL);
-      int oldUmask = conf.getInt(DEPRECATED_UMASK_LABEL, Integer.MIN_VALUE);
       try {
         if(confUmask != null) {
           umask = new UmaskParser(confUmask).getUMask();
@@ -290,7 +284,6 @@ public class FsPermission implements Writable {
   /** Set the user file creation mask (umask) */
   public static void setUMask(Configuration conf, FsPermission umask) {
     conf.set(UMASK_LABEL, String.format("%1$03o", umask.toShort()));
-    conf.setInt(DEPRECATED_UMASK_LABEL, umask.toShort());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b21dffb1/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
----------------------------------------------------------------------
diff --git 
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
 
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
index 45d6e1a..04dbe01 100644
--- 
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
+++ 
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
@@ -695,14 +695,4 @@ public class TestFsPermission extends TestCase {
            msg.contains(umask) &&
            msg.contains("octal or symbolic");
   }
-  
-  // Ensure that when the deprecated decimal umask key is used, it is correctly
-  // parsed as such and converted correctly to an FsPermission value
-  public void testDeprecatedUmask() {
-    Configuration conf = new Configuration();
-    conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "302"); // 302 = 0456
-    FsPermission umask = FsPermission.getUMask(conf);
-
-    assertEquals(0456, umask.toShort());
-  }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b21dffb1/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt 
b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 707684b..957087e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -868,6 +868,9 @@ Trunk (Unreleased)
       HDFS-9348. Erasure Coding: DFS GetErasureCodingPolicy API on a 
non-existent 
       file should be handled properly. (Rakesh R via umamahesh)
 
+      HDFS-9451. Clean up depreated umasks and related unit tests.
+      (Wei-Chiu Chuang via wheat9)
+
 Release 2.8.0 - UNRELEASED
 
   NEW FEATURES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b21dffb1/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java
index 425c82e..27af49c 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java
@@ -83,31 +83,18 @@ public class TestPermission {
     Configuration conf = new Configuration();
     FsPermission.setUMask(conf, perm);
     assertEquals(18, FsPermission.getUMask(conf).toShort());
-    
-    // Test 2 - old configuration key set with decimal 
-    // umask value should be handled
-    perm = new FsPermission((short)18);
-    conf = new Configuration();
-    conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "18");
-    assertEquals(18, FsPermission.getUMask(conf).toShort());
-    
-    // Test 3 - old configuration key overrides the new one
-    conf = new Configuration();
-    conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "18");
-    conf.set(FsPermission.UMASK_LABEL, "000");
-    assertEquals(18, FsPermission.getUMask(conf).toShort());
-    
-    // Test 4 - new configuration key is handled
+
+    // Test 2 - new configuration key is handled
     conf = new Configuration();
     conf.set(FsPermission.UMASK_LABEL, "022");
     assertEquals(18, FsPermission.getUMask(conf).toShort());
 
-    // Test 5 - equivalent valid umask
+    // Test 3 - equivalent valid umask
     conf = new Configuration();
     conf.set(FsPermission.UMASK_LABEL, "0022");
     assertEquals(18, FsPermission.getUMask(conf).toShort());
 
-    // Test 6 - invalid umask
+    // Test 4 - invalid umask
     conf = new Configuration();
     conf.set(FsPermission.UMASK_LABEL, "1222");
     try {
@@ -117,7 +104,7 @@ public class TestPermission {
      //pass, exception successfully trigger
     }
 
-    // Test 7 - invalid umask
+    // Test 5 - invalid umask
     conf = new Configuration();
     conf.set(FsPermission.UMASK_LABEL, "01222");
     try {

Reply via email to