From af8b413a9cebea0109ebdf16bd18078da3c551a1 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 1 Sep 2019 12:25:06 -0700 Subject: [PATCH] HCFS: fix mkdirs NPE --- .../client/src/main/java/seaweedfs/client/FilerClient.java | 7 +++---- .../src/test/java/seaweedfs/client/SeaweedFilerTest.java | 6 ++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java index f4bd0944b..2a40f3200 100644 --- a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java +++ b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java @@ -34,13 +34,12 @@ public class FilerClient { public boolean mkdirs(String path, int mode, int uid, int gid, String userName, String[] groupNames) { - Path pathObject = Paths.get(path); - String parent = pathObject.getParent().toString(); - String name = pathObject.getFileName().toString(); - if ("/".equals(path)) { return true; } + Path pathObject = Paths.get(path); + String parent = pathObject.getParent().toString(); + String name = pathObject.getFileName().toString(); mkdirs(parent, mode, uid, gid, userName, groupNames); diff --git a/other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java b/other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java index dde23ee87..87165af0c 100644 --- a/other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java +++ b/other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java @@ -13,5 +13,11 @@ public class SeaweedFilerTest { System.out.println(entry.toString()); } + filerClient.mkdirs("/new_folder", 0755); + filerClient.touch("/new_folder/new_empty_file", 0755); + filerClient.touch("/new_folder/new_empty_file2", 0755); + filerClient.rm("/new_folder/new_empty_file", false); + filerClient.rm("/new_folder", true); + } }