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 d4adbb59d9..b535fd6941 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 FsPermission applyUMask(FsPermission umask) { 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 FsPermission applyUMask(FsPermission umask) { * '-' 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 static FsPermission getUMask(Configuration conf) { // 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 boolean getEncryptedBit() { /** 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()); } /** 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 45d6e1acea..04dbe01471 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 @@ private boolean isCorrectExceptionMessage(String msg, String umask) { 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()); - } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 707684b50e..957087ec95 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 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 425c82ecb7..27af49c14c 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 void testBackwardCompatibility() { 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 void testBackwardCompatibility() { //pass, exception successfully trigger } - // Test 7 - invalid umask + // Test 5 - invalid umask conf = new Configuration(); conf.set(FsPermission.UMASK_LABEL, "01222"); try {