From c88c2af8bfa37ee74259cb2ccbd79a74ebb1c722 Mon Sep 17 00:00:00 2001 From: Sagar Sumit Date: Tue, 23 Nov 2021 08:43:10 +0530 Subject: [PATCH] [HUDI-2743] Assume path exists and defer fs.exists() in AbstractTableFileSystemView (#4002) --- .../table/view/AbstractTableFileSystemView.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java b/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java index b0687bb35..1a2ce01d8 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java @@ -315,13 +315,16 @@ public abstract class AbstractTableFileSystemView implements SyncableFileSystemV * @throws IOException */ protected FileStatus[] listPartition(Path partitionPath) throws IOException { - // Create the path if it does not exist already - if (!metaClient.getFs().exists(partitionPath)) { - metaClient.getFs().mkdirs(partitionPath); - return new FileStatus[0]; - } else { + try { return metaClient.getFs().listStatus(partitionPath); + } catch (IOException e) { + // Create the path if it does not exist already + if (!metaClient.getFs().exists(partitionPath)) { + metaClient.getFs().mkdirs(partitionPath); + return new FileStatus[0]; + } } + throw new HoodieIOException(String.format("Failed to list partition path: %s", partitionPath)); } /**