HADOOP-8299. ViewFileSystem link slash mount point crashes with IndexOutOfBoundsException. Contributed by Manoj Govindassamy.
This commit is contained in:
parent
55e1fb8e32
commit
22ff0eff4d
@ -302,6 +302,12 @@ protected InodeTree(final Configuration config, final String viewName)
|
|||||||
String src = key.substring(mtPrefix.length());
|
String src = key.substring(mtPrefix.length());
|
||||||
if (src.startsWith(linkPrefix)) {
|
if (src.startsWith(linkPrefix)) {
|
||||||
src = src.substring(linkPrefix.length());
|
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
|
} else if (src.startsWith(linkMergePrefix)) { // A merge link
|
||||||
isMergeLink = true;
|
isMergeLink = true;
|
||||||
src = src.substring(linkMergePrefix.length());
|
src = src.substring(linkMergePrefix.length());
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -35,6 +36,7 @@
|
|||||||
import org.apache.hadoop.fs.LocatedFileStatus;
|
import org.apache.hadoop.fs.LocatedFileStatus;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.RemoteIterator;
|
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.AclEntry;
|
||||||
import org.apache.hadoop.fs.permission.AclStatus;
|
import org.apache.hadoop.fs.permission.AclStatus;
|
||||||
import org.apache.hadoop.fs.permission.AclUtil;
|
import org.apache.hadoop.fs.permission.AclUtil;
|
||||||
@ -54,6 +56,8 @@
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.containsString;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
|
||||||
@ -922,4 +926,30 @@ public void testInternalGetAllStoragePolicies() throws IOException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user