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 8b357947e15c24ea6837291469bf64b8fc7c09b4 Author: XuQianJin-Stars <[email protected]> AuthorDate: Wed Jan 18 23:35:01 2023 +0800 fix readDataFromPath check fs exists --- .../common/table/timeline/HoodieActiveTimeline.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieActiveTimeline.java b/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieActiveTimeline.java index a3c7ab9e27e..19199cf4140 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieActiveTimeline.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieActiveTimeline.java @@ -27,6 +27,7 @@ import org.apache.hudi.common.util.Option; import org.apache.hudi.common.util.StringUtils; import org.apache.hudi.common.util.ValidationUtils; import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; import org.apache.hudi.exception.HoodieIOException; import org.apache.hadoop.fs.FSDataInputStream; @@ -774,10 +775,18 @@ public class HoodieActiveTimeline extends HoodieDefaultTimeline { } private Option<byte[]> readDataFromPath(Path detailPath) { - try (FSDataInputStream is = metaClient.getFs().open(detailPath)) { - return Option.of(FileIOUtils.readAsByteArray(is)); - } catch (IOException e) { - throw new HoodieIOException("Could not read commit details from " + detailPath, e); + try { + if (metaClient.getFs().exists(detailPath)) { + try (FSDataInputStream is = metaClient.getFs().open(detailPath)) { + return Option.of(FileIOUtils.readAsByteArray(is)); + } catch (IOException e) { + throw new HoodieIOException("Could not read commit details from " + detailPath, e); + } + } else { + return Option.empty(); + } + } catch (Exception e) { + throw new HoodieException("Could not read commit details from " + detailPath, e); } }
