diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index d81770d04a5..01651dcd376 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -41,6 +41,9 @@ Release 2.7.0 - UNRELEASED HDFS-7190. Bad use of Preconditions in startFileInternal(). (Dawson Choong via wheat9) + HDFS-7242. Code improvement for FSN#checkUnreadableBySuperuser. + (Yi Liu via vinayakumarb) + Release 2.6.0 - UNRELEASED INCOMPATIBLE CHANGES 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 cec146f82a4..7be6cc1e71e 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 @@ -6279,10 +6279,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats, private void checkUnreadableBySuperuser(FSPermissionChecker pc, INode inode, int snapshotId) throws IOException { - for (XAttr xattr : dir.getXAttrs(inode, snapshotId)) { - if (XAttrHelper.getPrefixName(xattr). - equals(SECURITY_XATTR_UNREADABLE_BY_SUPERUSER)) { - if (pc.isSuperUser()) { + if (pc.isSuperUser()) { + for (XAttr xattr : dir.getXAttrs(inode, snapshotId)) { + if (XAttrHelper.getPrefixName(xattr). + equals(SECURITY_XATTR_UNREADABLE_BY_SUPERUSER)) { throw new AccessControlException("Access is denied for " + pc.getUser() + " since the superuser is not allowed to " + "perform this operation.");