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 5d97593173..5209b98100 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 @@ -7437,10 +7437,10 @@ void createEncryptionZone(final String src, final String keyName, Metadata metadata = FSDirEncryptionZoneOp.ensureKeyIsInitialized(dir, keyName, src); final FSPermissionChecker pc = getPermissionChecker(); + checkSuperuserPrivilege(pc); checkOperation(OperationCategory.WRITE); writeLock(); try { - checkSuperuserPrivilege(pc); checkOperation(OperationCategory.WRITE); checkNameNodeSafeMode("Cannot create encryption zone on " + src); resultingStat = FSDirEncryptionZoneOp.createEncryptionZone(dir, src, @@ -7496,10 +7496,10 @@ BatchedListEntries listEncryptionZones(long prevId) boolean success = false; checkOperation(OperationCategory.READ); final FSPermissionChecker pc = getPermissionChecker(); + checkSuperuserPrivilege(pc); readLock(); try { checkOperation(OperationCategory.READ); - checkSuperuserPrivilege(pc); final BatchedListEntries ret = FSDirEncryptionZoneOp.listEncryptionZones(dir, prevId); success = true; @@ -7533,10 +7533,10 @@ BatchedListEntries listReencryptionStatus( boolean success = false; checkOperation(OperationCategory.READ); final FSPermissionChecker pc = getPermissionChecker(); + checkSuperuserPrivilege(pc); readLock(); try { checkOperation(OperationCategory.READ); - checkSuperuserPrivilege(pc); final BatchedListEntries ret = FSDirEncryptionZoneOp.listReencryptionStatus(dir, prevId); success = true; @@ -7567,7 +7567,6 @@ private void reencryptEncryptionZoneInt(final FSPermissionChecker pc, } writeLock(); try { - checkSuperuserPrivilege(pc); checkOperation(OperationCategory.WRITE); checkNameNodeSafeMode("NameNode in safemode, cannot " + action + " re-encryption on zone " + zone);