You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "OneSizeFitsQuorum (via GitHub)" <gi...@apache.org> on 2023/07/07 02:31:20 UTC

[GitHub] [ratis] OneSizeFitsQuorum commented on a diff in pull request #892: RATIS-1855 Fix some sonar code smell and bugs in ratis-server

OneSizeFitsQuorum commented on code in PR #892:
URL: https://github.com/apache/ratis/pull/892#discussion_r1255161529


##########
ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java:
##########
@@ -39,7 +40,7 @@ public class RaftStorageImpl implements RaftStorage {
   private final StartupOption startupOption;
   private final CorruptionPolicy logCorruptionPolicy;
   private volatile StorageState state = StorageState.UNINITIALIZED;
-  private volatile RaftStorageMetadataFileImpl metaFile;
+  private final AtomicReference<RaftStorageMetadataFileImpl> metaFile = new AtomicReference<>();

Review Comment:
   Good advice~



##########
ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java:
##########
@@ -91,9 +92,9 @@ public CorruptionPolicy getLogCorruptionPolicy() {
 
   private void format() throws IOException {
     storageDir.clearDirectory();
-    metaFile = new RaftStorageMetadataFileImpl(storageDir.getMetaFile());
-    metaFile.persist(RaftStorageMetadata.getDefault());
-    LOG.info("Storage directory " + storageDir.getRoot() + " has been successfully formatted.");
+    metaFile.set(new RaftStorageMetadataFileImpl(storageDir.getMetaFile()));
+    metaFile.get().persist(RaftStorageMetadata.getDefault());

Review Comment:
   OK



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org