diff options
Diffstat (limited to 'exec/java-exec/src/main/java/org/apache/drill/exec/util/DrillFileSystemUtil.java')
-rw-r--r-- | exec/java-exec/src/main/java/org/apache/drill/exec/util/DrillFileSystemUtil.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/util/DrillFileSystemUtil.java b/exec/java-exec/src/main/java/org/apache/drill/exec/util/DrillFileSystemUtil.java index fcee3b0e0..bfb83e07c 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/util/DrillFileSystemUtil.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/util/DrillFileSystemUtil.java @@ -18,6 +18,7 @@ package org.apache.drill.exec.util; import org.apache.drill.exec.store.dfs.DrillFileSystem; +import org.apache.drill.shaded.guava.com.google.common.base.Strings; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; @@ -133,4 +134,14 @@ public class DrillFileSystemUtil { return FileSystemUtil.listAllSafe(fs, path, recursive, FileSystemUtil.mergeFilters(DRILL_SYSTEM_FILTER, filters)); } + /** + * Safely creates Hadoop Path for null and empty String paths + * + * @param path String path, which can be null or empty + * @return Hadoop Path. Root - for empty or null path + */ + public static Path createPathSafe(String path) { + return Strings.isNullOrEmpty(path) ? new Path("/") : new Path(path); + } + } |