HDFS-16496. Snapshot diff on snapshotable directory fails with not snapshottable error (#4051)

This commit is contained in:
Stephen O'Donnell 2022-03-08 11:07:11 +00:00 committed by GitHub
parent 66b72406bd
commit 49e4e4d0a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -391,8 +391,8 @@ public class SnapshotManager implements SnapshotStatsMXBean {
final INodesInPath iip) throws IOException {
final INodeDirectory dir = getSnapshottableAncestorDir(iip);
if (dir == null) {
throw new SnapshotException("Directory is neither snapshottable nor" +
" under a snap root!");
throw new SnapshotException("The path " + iip.getPath()
+ " is neither snapshottable nor under a snapshot root!");
}
return dir;
}
@ -402,7 +402,7 @@ public class SnapshotManager implements SnapshotStatsMXBean {
final String path = iip.getPath();
final INode inode = iip.getLastINode();
final INodeDirectory dir;
if (inode instanceof INodeDirectory) {
if (inode != null && inode.isDirectory()) {
dir = INodeDirectory.valueOf(inode, path);
} else {
dir = INodeDirectory.valueOf(iip.getINode(-2), iip.getParentPath());

View File

@ -345,7 +345,8 @@ public class TestSnapshotDiffReport {
+ nonSnapDir.getName() + "'should fail!");
} catch (SnapshotException e) {
GenericTestUtils.assertExceptionContains(
"Directory is neither snapshottable nor under a snap root!", e);
"The path " + nonSnapDir +
" is neither snapshottable nor under a snapshot root!", e);
}
final String invalidName = "invalid";