This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new c3d615b4f RATIS-2047. Avoid unnecessary warn log when creating raft
group (#1054)
c3d615b4f is described below
commit c3d615b4f28b92e1d271b84752f1c9b0fc23341c
Author: Potato <[email protected]>
AuthorDate: Sat Mar 23 00:53:30 2024 +0800
RATIS-2047. Avoid unnecessary warn log when creating raft group (#1054)
---
.../apache/ratis/server/storage/RaftStorageImpl.java | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java
b/ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java
index fbb7bf7d4..ce809cad8 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java
@@ -19,7 +19,6 @@ package org.apache.ratis.server.storage;
import java.io.InputStream;
import java.io.OutputStream;
-import java.nio.file.NoSuchFileException;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ratis.proto.RaftProtos.LogEntryProto;
import org.apache.ratis.server.RaftConfiguration;
@@ -153,14 +152,16 @@ public class RaftStorageImpl implements RaftStorage {
public RaftConfiguration readRaftConfiguration() {
File confFile = storageDir.getMetaConfFile();
- try (InputStream fio = FileUtils.newInputStream(confFile)) {
- LogEntryProto confProto =
LogEntryProto.newBuilder().mergeFrom(fio).build();
- return LogProtoUtils.toRaftConfiguration(confProto);
- } catch (FileNotFoundException | NoSuchFileException e) {
- return null;
- } catch (Exception e) {
- LOG.error("Failed reading configuration from file:" + confFile, e);
+ if (!confFile.exists()) {
return null;
+ } else {
+ try (InputStream fio = FileUtils.newInputStream(confFile)) {
+ LogEntryProto confProto =
LogEntryProto.newBuilder().mergeFrom(fio).build();
+ return LogProtoUtils.toRaftConfiguration(confProto);
+ } catch (Exception e) {
+ LOG.error("Failed reading configuration from file:" + confFile, e);
+ return null;
+ }
}
}