HDFS-16351. Add path exception information in FSNamesystem (#3713). Contributed by guophilipse.

Reviewed-by: Viraj Jasani <vjasani@apache.org>
Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
GuoPhilipse 2021-12-07 16:49:27 +08:00 committed by GitHub
parent 7a8c2e0097
commit 80cccc5376
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -8612,7 +8612,7 @@ void checkAccess(String src, FsAction mode) throws IOException {
src = iip.getPath();
INode inode = iip.getLastINode();
if (inode == null) {
throw new FileNotFoundException("Path not found");
throw new FileNotFoundException("Path not found: " + src);
}
if (isPermissionEnabled) {
dir.checkPathAccess(pc, iip, mode);

View File

@ -44,6 +44,7 @@
import org.apache.hadoop.fs.permission.FsAction;
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.test.LambdaTestUtils;
import org.apache.hadoop.util.Time;
import org.junit.After;
import org.junit.Before;
@ -260,6 +261,17 @@ private void createAndCheckPermission(OpType op, Path name, short umask,
checkPermission(name, expectedPermission, delete);
}
@Test
public void testFSNamesystemCheckAccess() throws Exception{
Path testInvalidPath = new Path("/test2");
fs = FileSystem.get(conf);
LambdaTestUtils.intercept(
FileNotFoundException.class,
"Path not found: " + testInvalidPath,
() -> fs.access(testInvalidPath, FsAction.READ));
}
/* Check if the permission of a file/directory is the same as the
* expected permission; If the delete flag is true, delete the
* file/directory afterwards.