diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java index 6b1093e7969..5c16a4e9f36 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java @@ -57,8 +57,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; } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFs.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFs.java index d77ad8b96e3..ad1f5b56204 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFs.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFs.java @@ -101,8 +101,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)); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFs.java index 27d093c2b0a..a2f09057ce6 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFs.java +++ b/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()) {}; + } + }