This is an automated email from the ASF dual-hosted git repository. forwardxu pushed a commit to branch release-0.12.1 in repository https://gitbox.apache.org/repos/asf/hudi.git
commit e45564102b0d7e0d4ff35152262274de7737af0e Author: XuQianJin-Stars <[email protected]> AuthorDate: Sun Oct 9 17:20:41 2022 +0800 fix file not exists for getFileSize --- .../src/main/java/org/apache/hudi/common/fs/FSUtils.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java b/hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java index 0257f8015b..1350108a11 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java @@ -191,8 +191,18 @@ public class FSUtils { return fullFileName.split("_")[2].split("\\.")[0]; } - public static long getFileSize(FileSystem fs, Path path) throws IOException { - return fs.getFileStatus(path).getLen(); + public static long getFileSize(FileSystem fs, Path path) { + try { + if (fs.exists(path)) { + return fs.getFileStatus(path).getLen(); + } else { + LOG.warn("getFileSize: " + path + " file not exists!"); + return 0L; + } + } catch (IOException e) { + LOG.error("getFileSize: " + path + " error:", e); + return 0L; + } } public static String getFileId(String fullFileName) {
