HADOOP-17059. ArrayIndexOfboundsException in ViewFileSystem#listStatus. Contributed by hemanthboyina

This commit is contained in:
Mingliang Liu 2020-06-10 09:03:57 -07:00
parent af324e3153
commit 8e01bd317b
No known key found for this signature in database
GPG Key ID: BC2FB8C6908A0C16
2 changed files with 25 additions and 1 deletions

View File

@ -1018,7 +1018,7 @@ public class ViewFileSystem extends FileSystem {
} else {
result[i++] = new FileStatus(0, true, 0, 0,
creationTime, creationTime, PERMISSION_555,
ugi.getShortUserName(), ugi.getGroupNames()[0],
ugi.getShortUserName(), ugi.getPrimaryGroupName(),
new Path(inode.fullPath).makeQualified(
myUri, null));
}

View File

@ -55,6 +55,7 @@ import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.RemoteIterator;
import org.apache.hadoop.fs.FileContextTestHelper.fileType;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FsConstants;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.UnresolvedLinkException;
@ -1003,4 +1004,27 @@ abstract public class ViewFsBaseTest {
return mockFs;
}
}
@Test
public void testListStatusWithNoGroups() throws Exception {
final UserGroupInformation userUgi = UserGroupInformation
.createUserForTesting("user@HADOOP.COM", new String[] {});
userUgi.doAs(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
String clusterName = Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE;
URI viewFsUri =
new URI(FsConstants.VIEWFS_SCHEME, clusterName, "/", null, null);
FileSystem vfs = FileSystem.get(viewFsUri, conf);
try {
vfs.listStatus(new Path(viewFsUri.toString() + "internalDir"));
Assert.fail("Exception should be thrown.");
} catch (IOException e) {
GenericTestUtils
.assertExceptionContains("There is no primary group for UGI", e);
}
return null;
}
});
}
}