You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by ji...@apache.org on 2023/01/20 05:11:36 UTC

[rocketmq] branch develop updated: [ISSUE #5905] fix config file disappear after vm crash

This is an automated email from the ASF dual-hosted git repository.

jinrongtong pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new a961a9b37 [ISSUE #5905] fix config file disappear after vm crash
a961a9b37 is described below

commit a961a9b37b0e9e4c6e30d7cc6ab1a9c796634e6f
Author: yuz10 <84...@qq.com>
AuthorDate: Fri Jan 20 13:11:30 2023 +0800

    [ISSUE #5905] fix config file disappear after vm crash
---
 common/src/main/java/org/apache/rocketmq/common/MixAll.java | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/common/src/main/java/org/apache/rocketmq/common/MixAll.java b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
index d173e206d..3214bd838 100644
--- a/common/src/main/java/org/apache/rocketmq/common/MixAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
@@ -179,10 +179,7 @@ public class MixAll {
         return 0;
     }
 
-    public static void string2File(final String str, final String fileName) throws IOException {
-
-        String tmpFile = fileName + ".tmp";
-        string2FileNotSafe(str, tmpFile);
+    public static synchronized void string2File(final String str, final String fileName) throws IOException {
 
         String bakFile = fileName + ".bak";
         String prevContent = file2String(fileName);
@@ -190,11 +187,7 @@ public class MixAll {
             string2FileNotSafe(prevContent, bakFile);
         }
 
-        File file = new File(fileName);
-        file.delete();
-
-        file = new File(tmpFile);
-        file.renameTo(new File(fileName));
+        string2FileNotSafe(str, fileName);
     }
 
     public static void string2FileNotSafe(final String str, final String fileName) throws IOException {