Преглед на файлове

HADOOP-14211. FilterFs and ChRootedFs are too aggressive about enforcing 'authorityNeeded'. Contributed by Erik Krogen.

(cherry picked from commit 0e556a5ba645570d381beca60114a1239b27d49f)
(cherry picked from commit 96fe940e59127dc7c3e4182c3ed450c3cd8d858e)
(cherry picked from commit 5130128a31a75587f6ccca08c487e44f73685227)
Andrew Wang преди 8 години
родител
ревизия
295aab8e3a

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -123,6 +123,9 @@ Release 2.7.4 - UNRELEASED
     HADOOP-9631. ViewFs should use underlying FileSystem's server side defaults.
     (Lohit Vijayarenu and Erik Krogen via zhz)
 
+    HADOOP-14211. FilterFs and ChRootedFs are too aggressive about enforcing
+    "authorityNeeded". (Erik Krogen via wang)
+
 Release 2.7.3 - 2016-08-25
 
   INCOMPATIBLE CHANGES

+ 1 - 2
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java

@@ -56,8 +56,7 @@ public abstract class FilterFs extends AbstractFileSystem {
   }
   
   protected FilterFs(AbstractFileSystem fs) throws URISyntaxException {
-    super(fs.getUri(), fs.getUri().getScheme(),
-        fs.getUri().getAuthority() != null, fs.getUriDefaultPort());
+    super(fs.getUri(), fs.getUri().getScheme(), false, fs.getUriDefaultPort());
     myFs = fs;
   }
 

+ 1 - 2
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFs.java

@@ -99,8 +99,7 @@ class ChRootedFs extends AbstractFileSystem {
 
   public ChRootedFs(final AbstractFileSystem fs, final Path theRoot)
     throws URISyntaxException {
-    super(fs.getUri(), fs.getUri().getScheme(),
-        fs.getUri().getAuthority() != null, fs.getUriDefaultPort());
+    super(fs.getUri(), fs.getUri().getScheme(), false, fs.getUriDefaultPort());
     myFs = fs;
     myFs.checkPath(theRoot);
     chRootPathPart = new Path(myFs.getUriPath(theRoot));

+ 12 - 0
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFs.java

@@ -25,6 +25,8 @@ import java.util.Iterator;
 
 import junit.framework.TestCase;
 import org.apache.commons.logging.Log;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.viewfs.ConfigUtil;
 
 public class TestFilterFs extends TestCase {
 
@@ -65,4 +67,14 @@ public class TestFilterFs extends TestCase {
     }
   }
   
+  // Test that FilterFs will accept an AbstractFileSystem to be filtered which
+  // has an optional authority, such as ViewFs
+  public void testFilteringWithNonrequiredAuthority() throws Exception {
+    Configuration conf = new Configuration();
+    ConfigUtil.addLink(conf, "custom", "/mnt", URI.create("file:///"));
+    FileContext fc =
+        FileContext.getFileContext(URI.create("viewfs://custom/"), conf);
+    new FilterFs(fc.getDefaultFileSystem()) {};
+  }
+
 }