You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by li...@apache.org on 2020/06/10 16:04:27 UTC

[hadoop] branch branch-2.10 updated: HADOOP-17059. ArrayIndexOfboundsException in ViewFileSystem#listStatus. Contributed by hemanthboyina

This is an automated email from the ASF dual-hosted git repository.

liuml07 pushed a commit to branch branch-2.10
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-2.10 by this push:
     new 8e01bd3  HADOOP-17059. ArrayIndexOfboundsException in ViewFileSystem#listStatus. Contributed by hemanthboyina
8e01bd3 is described below

commit 8e01bd317b7aede1f0bf6c9a55f8ee435da0fb84
Author: Mingliang Liu <li...@apache.org>
AuthorDate: Wed Jun 10 09:03:57 2020 -0700

    HADOOP-17059. ArrayIndexOfboundsException in ViewFileSystem#listStatus. Contributed by hemanthboyina
---
 .../apache/hadoop/fs/viewfs/ViewFileSystem.java    |  2 +-
 .../apache/hadoop/fs/viewfs/ViewFsBaseTest.java    | 24 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
index c248a27..7960048 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
@@ -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));
         }
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
index 73e43e1..62d3117 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
@@ -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;
+      }
+    });
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org