Skip to content

Commit

Permalink
HDFS-15515: mkdirs on fallback should throw IOE out instead of suppre…
Browse files Browse the repository at this point in the history
…ssing and returning false (apache#2205)

* HDFS-15515: mkdirs on fallback should throw IOE out instead of suppressing and returning false

* Used LambdaTestUtils#intercept in test
  • Loading branch information
umamaheswararao committed Aug 11, 2020
1 parent 592127b commit 8955a6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,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");
}
Expand Down Expand Up @@ -1451,16 +1451,15 @@ public boolean mkdirs(Path dir, FsPermission permission)
.append(linkedFallbackFs.getUri());
LOG.debug(msg.toString(), e);
}
return false;
throw e;
}
}

throw readOnlyMountTable("mkdirs", dir);
}

@Override
public boolean mkdirs(Path dir)
throws AccessControlException, FileAlreadyExistsException {
public boolean mkdirs(Path dir) throws IOException {
return mkdirs(dir, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 8955a6c

Please sign in to comment.