This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 695b901bfa check and create log file in the init function of
SnapshotLogger (#7151)
695b901bfa is described below
commit 695b901bfa9cb0646e2fb58bc5f5ccf167a8e4ea
Author: Liu Xuxin <[email protected]>
AuthorDate: Mon Aug 29 11:48:09 2022 +0800
check and create log file in the init function of SnapshotLogger (#7151)
---
.../java/org/apache/iotdb/db/engine/snapshot/SnapshotLogger.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git
a/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotLogger.java
b/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotLogger.java
index fe1937fbcf..b2b8c06ba5 100644
---
a/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotLogger.java
+++
b/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotLogger.java
@@ -20,7 +20,6 @@ package org.apache.iotdb.db.engine.snapshot;
import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -33,8 +32,14 @@ public class SnapshotLogger implements AutoCloseable {
private File logFile;
private BufferedOutputStream os;
- public SnapshotLogger(File logFile) throws FileNotFoundException {
+ public SnapshotLogger(File logFile) throws IOException {
this.logFile = logFile;
+ if (!logFile.getParentFile().exists() &&
!logFile.getParentFile().mkdirs()) {
+ throw new IOException("Cannot create parent folder for " +
logFile.getAbsolutePath());
+ }
+ if (!this.logFile.createNewFile()) {
+ throw new IOException("Cannot create file " + logFile.getAbsolutePath());
+ }
os = new BufferedOutputStream(new FileOutputStream(logFile));
}