HDFS-11275. Check groupEntryIndex and throw a helpful exception on failures when removing ACL.

This commit is contained in:
Xiao Chen 2016-12-29 10:36:50 -08:00
parent a4f66655ec
commit e769957556

View File

@ -17,6 +17,7 @@
*/ */
package org.apache.hadoop.hdfs.server.namenode; package org.apache.hadoop.hdfs.server.namenode;
import com.google.common.base.Preconditions;
import org.apache.hadoop.fs.permission.AclEntry; import org.apache.hadoop.fs.permission.AclEntry;
import org.apache.hadoop.fs.permission.AclEntryScope; import org.apache.hadoop.fs.permission.AclEntryScope;
import org.apache.hadoop.fs.permission.AclEntryType; import org.apache.hadoop.fs.permission.AclEntryType;
@ -221,7 +222,10 @@ private static void unprotectedRemoveAcl(FSDirectory fsd, INodesInPath iip)
int groupEntryIndex = Collections.binarySearch( int groupEntryIndex = Collections.binarySearch(
featureEntries, groupEntryKey, featureEntries, groupEntryKey,
AclTransformation.ACL_ENTRY_COMPARATOR); AclTransformation.ACL_ENTRY_COMPARATOR);
assert groupEntryIndex >= 0; Preconditions.checkPositionIndex(groupEntryIndex, featureEntries.size(),
"Invalid group entry index after binary-searching inode: " +
inode.getFullPathName() + "(" + inode.getId() + ") "
+ "with featureEntries:" + featureEntries);
FsAction groupPerm = featureEntries.get(groupEntryIndex).getPermission(); FsAction groupPerm = featureEntries.get(groupEntryIndex).getPermission();
FsPermission newPerm = new FsPermission(perm.getUserAction(), groupPerm, FsPermission newPerm = new FsPermission(perm.getUserAction(), groupPerm,
perm.getOtherAction(), perm.getStickyBit()); perm.getOtherAction(), perm.getStickyBit());