Skip to content

Commit 80cccc5

Browse files
authored
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>
1 parent 7a8c2e0 commit 80cccc5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8612,7 +8612,7 @@ void checkAccess(String src, FsAction mode) throws IOException {
86128612
src = iip.getPath();
86138613
INode inode = iip.getLastINode();
86148614
if (inode == null) {
8615-
throw new FileNotFoundException("Path not found");
8615+
throw new FileNotFoundException("Path not found: " + src);
86168616
}
86178617
if (isPermissionEnabled) {
86188618
dir.checkPathAccess(pc, iip, mode);

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSPermission.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.apache.hadoop.fs.permission.FsAction;
4545
import org.apache.hadoop.security.AccessControlException;
4646
import org.apache.hadoop.security.UserGroupInformation;
47+
import org.apache.hadoop.test.LambdaTestUtils;
4748
import org.apache.hadoop.util.Time;
4849
import org.junit.After;
4950
import org.junit.Before;
@@ -260,6 +261,17 @@ private void createAndCheckPermission(OpType op, Path name, short umask,
260261
checkPermission(name, expectedPermission, delete);
261262
}
262263

264+
@Test
265+
public void testFSNamesystemCheckAccess() throws Exception{
266+
Path testInvalidPath = new Path("/test2");
267+
fs = FileSystem.get(conf);
268+
269+
LambdaTestUtils.intercept(
270+
FileNotFoundException.class,
271+
"Path not found: " + testInvalidPath,
272+
() -> fs.access(testInvalidPath, FsAction.READ));
273+
}
274+
263275
/* Check if the permission of a file/directory is the same as the
264276
* expected permission; If the delete flag is true, delete the
265277
* file/directory afterwards.

0 commit comments

Comments
 (0)