HDFS-15563. Incorrect getTrashRoot return value when a non-snapshottable dir prefix matches the path of a snapshottable dir (#2295)
Change-Id: Iefcbc14ca939b61f0c1befc9a94d686be1684ddc
This commit is contained in:
parent
e5fe326270
commit
43c52d6495
|
@ -3168,6 +3168,9 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
|
|||
}
|
||||
for (SnapshottableDirectoryStatus dirStatus : dirStatusList) {
|
||||
String currDir = dirStatus.getFullPath().toString();
|
||||
if (!currDir.endsWith(Path.SEPARATOR)) {
|
||||
currDir += Path.SEPARATOR;
|
||||
}
|
||||
if (path.toUri().getPath().startsWith(currDir)) {
|
||||
return currDir;
|
||||
}
|
||||
|
|
|
@ -2172,9 +2172,19 @@ public class TestDistributedFileSystem {
|
|||
String testDirStr = testDir.toUri().getPath();
|
||||
assertTrue(trAfterAllowSnapshotStr.startsWith(testDirStr));
|
||||
|
||||
// test2Dir has the same prefix as testDir, but not snapshottable
|
||||
Path test2Dir = new Path("/ssgtr/test12/");
|
||||
Path file1path = new Path(test2Dir, "file-1");
|
||||
trAfterAllowSnapshot = dfs.getTrashRoot(file1path);
|
||||
trAfterAllowSnapshotStr = trAfterAllowSnapshot.toUri().getPath();
|
||||
// The trash root should not be in the snapshot root
|
||||
assertFalse(trAfterAllowSnapshotStr.startsWith(testDirStr));
|
||||
assertTrue(trBeforeAllowSnapshotStr.startsWith(homeDirStr));
|
||||
|
||||
// Cleanup
|
||||
dfs.disallowSnapshot(testDir);
|
||||
dfs.delete(testDir, true);
|
||||
dfs.delete(test2Dir, true);
|
||||
} finally {
|
||||
if (cluster != null) {
|
||||
cluster.shutdown();
|
||||
|
|
Loading…
Reference in New Issue