diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java index b44148399ddce..f545165f019f9 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java @@ -1382,7 +1382,7 @@ public FsStatus getStatus(Path p) throws IOException { @Override public boolean mkdirs(Path dir, FsPermission permission) - throws AccessControlException, FileAlreadyExistsException { + throws IOException { if (theInternalDir.isRoot() && dir == null) { throw new FileAlreadyExistsException("/ already exits"); } @@ -1412,7 +1412,7 @@ public boolean mkdirs(Path dir, FsPermission permission) .append(linkedFallbackFs.getUri()); LOG.debug(msg.toString(), e); } - return false; + throw e; } } @@ -1420,8 +1420,7 @@ public boolean mkdirs(Path dir, FsPermission permission) } @Override - public boolean mkdirs(Path dir) - throws AccessControlException, FileAlreadyExistsException { + public boolean mkdirs(Path dir) throws IOException { return mkdirs(dir, null); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java index bd2b5af02ad87..e7317608147be 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.fs.viewfs; +import static org.apache.hadoop.test.LambdaTestUtils.intercept; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -759,7 +760,9 @@ public void testMkdirsShouldReturnFalseWhenFallbackFSNotAvailable() cluster.shutdownNameNodes(); // Stopping fallback server // /user1/test1 does not exist in mount internal dir tree, it would // attempt to create in fallback. - assertFalse(vfs.mkdirs(nextLevelToInternalDir)); + intercept(IOException.class, () -> { + vfs.mkdirs(nextLevelToInternalDir); + }); cluster.restartNameNodes(); // should return true succeed when fallback fs is back to normal. assertTrue(vfs.mkdirs(nextLevelToInternalDir));