Repository: hbase Updated Branches: refs/heads/branch-1 3a0a3fd5f -> 5d710bbe7
HBASE-18312 Ineffective handling of FileNotFoundException in FileLink.tryOpen() Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/5d710bbe Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/5d710bbe Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/5d710bbe Branch: refs/heads/branch-1 Commit: 5d710bbe7f3224f572399971346595dc6d7f5cbb Parents: 3a0a3fd Author: tedyu <[email protected]> Authored: Wed Jul 5 21:02:28 2017 -0700 Committer: tedyu <[email protected]> Committed: Wed Jul 5 21:02:28 2017 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/io/FileLink.java | 4 +++ .../apache/hadoop/hbase/io/TestFileLink.java | 31 ++++++++++++++++++++ 2 files changed, 35 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/5d710bbe/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java index 3caf67f..beeb8af 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java @@ -36,6 +36,7 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.PositionedReadable; import org.apache.hadoop.fs.Seekable; import org.apache.hadoop.hbase.util.FSUtils; +import org.apache.hadoop.ipc.RemoteException; /** * The FileLink is a sort of hardlink, that allows access to a file given a set of locations. @@ -302,6 +303,9 @@ public class FileLink { return(in); } catch (FileNotFoundException e) { // Try another file location + } catch (RemoteException re) { + IOException ioe = re.unwrapRemoteException(FileNotFoundException.class); + if (!(ioe instanceof FileNotFoundException)) throw re; } } throw new FileNotFoundException("Unable to open link: " + fileLink); http://git-wip-us.apache.org/repos/asf/hbase/blob/5d710bbe/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestFileLink.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestFileLink.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestFileLink.java index da2c7a0..2f1d4ab 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestFileLink.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestFileLink.java @@ -36,7 +36,9 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.FSUtils; +import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.MiniDFSCluster; +import org.apache.hadoop.ipc.RemoteException; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -104,6 +106,35 @@ public class TestFileLink { } } + private static class MyDistributedFileSystem extends DistributedFileSystem { + MyDistributedFileSystem() { + } + @Override + public FSDataInputStream open(Path f, final int bufferSize) + throws IOException { + throw new RemoteException(FileNotFoundException.class.getName(), ""); + } + @Override + public Configuration getConf() { + return new Configuration(); + } + } + @Test(expected = FileNotFoundException.class) + public void testLinkReadWithMissingFile() throws Exception { + HBaseTestingUtility testUtil = new HBaseTestingUtility(); + FileSystem fs = new MyDistributedFileSystem(); + + Path originalPath = new Path(testUtil.getDefaultRootDirPath(), "test.file"); + Path archivedPath = new Path(testUtil.getDefaultRootDirPath(), "archived.file"); + + List<Path> files = new ArrayList<Path>(); + files.add(originalPath); + files.add(archivedPath); + + FileLink link = new FileLink(files); + link.open(fs); + } + /** * Test, on a local filesystem, that the FileLink is still readable * even when the current file gets renamed.
