HDFS-13280. WebHDFS: Fix NPE in get snasphottable directory list call. Contributed by Lokesh Jain.
This commit is contained in:
parent
e71bc00a47
commit
78b05fde6c
@ -533,6 +533,9 @@ private static Object toJsonMap(
|
||||
|
||||
public static String toJsonString(
|
||||
SnapshottableDirectoryStatus[] snapshottableDirectoryList) {
|
||||
if (snapshottableDirectoryList == null) {
|
||||
return toJsonString("SnapshottableDirectoryList", null);
|
||||
}
|
||||
Object[] a = new Object[snapshottableDirectoryList.length];
|
||||
for (int i = 0; i < snapshottableDirectoryList.length; i++) {
|
||||
a[i] = toJsonMap(snapshottableDirectoryList[i]);
|
||||
|
@ -755,14 +755,16 @@ public void testWebHdfsSnapshottableDirectoryList() throws Exception {
|
||||
final Path bar = new Path("/bar");
|
||||
dfs.mkdirs(foo);
|
||||
dfs.mkdirs(bar);
|
||||
SnapshottableDirectoryStatus[] statuses =
|
||||
webHdfs.getSnapshottableDirectoryList();
|
||||
Assert.assertNull(statuses);
|
||||
dfs.allowSnapshot(foo);
|
||||
dfs.allowSnapshot(bar);
|
||||
Path file0 = new Path(foo, "file0");
|
||||
DFSTestUtil.createFile(dfs, file0, 100, (short) 1, 0);
|
||||
Path file1 = new Path(bar, "file1");
|
||||
DFSTestUtil.createFile(dfs, file1, 100, (short) 1, 0);
|
||||
SnapshottableDirectoryStatus[] statuses =
|
||||
webHdfs.getSnapshottableDirectoryList();
|
||||
statuses = webHdfs.getSnapshottableDirectoryList();
|
||||
SnapshottableDirectoryStatus[] dfsStatuses =
|
||||
dfs.getSnapshottableDirListing();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user