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 wa...@apache.org on 2016/10/26 21:25:07 UTC

hadoop git commit: HADOOP-8299. ViewFileSystem link slash mount point crashes with IndexOutOfBoundsException. Contributed by Manoj Govindassamy.

Repository: hadoop
Updated Branches:
  refs/heads/trunk 55e1fb8e3 -> 22ff0eff4


HADOOP-8299. ViewFileSystem link slash mount point crashes with IndexOutOfBoundsException. Contributed by Manoj Govindassamy.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/22ff0eff
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/22ff0eff
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/22ff0eff

Branch: refs/heads/trunk
Commit: 22ff0eff4d58ac0beda7a5a3ae0e5d108da14f7f
Parents: 55e1fb8
Author: Andrew Wang <wa...@apache.org>
Authored: Wed Oct 26 14:25:03 2016 -0700
Committer: Andrew Wang <wa...@apache.org>
Committed: Wed Oct 26 14:25:03 2016 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/fs/viewfs/InodeTree.java  |  6 ++++
 .../fs/viewfs/ViewFileSystemBaseTest.java       | 30 ++++++++++++++++++++
 2 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/22ff0eff/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
index a485a3b..c62d5cc 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
@@ -302,6 +302,12 @@ abstract class InodeTree<T> {
         String src = key.substring(mtPrefix.length());
         if (src.startsWith(linkPrefix)) {
           src = src.substring(linkPrefix.length());
+          if (src.equals(SlashPath.toString())) {
+            throw new UnsupportedFileSystemException("Unexpected mount table "
+                + "link entry '" + key + "'. "
+                + Constants.CONFIG_VIEWFS_LINK_MERGE_SLASH  + " is not "
+                + "supported yet.");
+          }
         } else if (src.startsWith(linkMergePrefix)) { // A merge link
           isMergeLink = true;
           src = src.substring(linkMergePrefix.length());

http://git-wip-us.apache.org/repos/asf/hadoop/blob/22ff0eff/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
index 9ec150f..7393af6 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.fs.viewfs;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.net.URI;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -35,6 +36,7 @@ import org.apache.hadoop.fs.FsConstants;
 import org.apache.hadoop.fs.LocatedFileStatus;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.RemoteIterator;
+import org.apache.hadoop.fs.UnsupportedFileSystemException;
 import org.apache.hadoop.fs.permission.AclEntry;
 import org.apache.hadoop.fs.permission.AclStatus;
 import org.apache.hadoop.fs.permission.AclUtil;
@@ -54,6 +56,8 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.*;
 
 
@@ -922,4 +926,30 @@ abstract public class ViewFileSystemBaseTest {
     }
   }
 
+  @Test
+  public void testConfLinkSlash() throws Exception {
+    String clusterName = "ClusterX";
+    URI viewFsUri = new URI(FsConstants.VIEWFS_SCHEME, clusterName,
+        "/", null, null);
+
+    Configuration newConf = new Configuration();
+    ConfigUtil.addLink(newConf, clusterName, "/",
+        new Path(targetTestRoot, "/").toUri());
+
+    String mtPrefix = Constants.CONFIG_VIEWFS_PREFIX + "." + clusterName + ".";
+    try {
+      FileSystem.get(viewFsUri, newConf);
+      fail("ViewFileSystem should error out on mount table entry: "
+          + mtPrefix + Constants.CONFIG_VIEWFS_LINK + "." + "/");
+    } catch (Exception e) {
+      if (e instanceof UnsupportedFileSystemException) {
+        String msg = Constants.CONFIG_VIEWFS_LINK_MERGE_SLASH
+            + " is not supported yet.";
+        assertThat(e.getMessage(), containsString(msg));
+      } else {
+        fail("Unexpected exception: " + e.getMessage());
+      }
+    }
+  }
+
 }


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