You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/08/12 02:18:34 UTC

[GitHub] [rocketmq] tsunghanjacktsai commented on a diff in pull request #4661: [ISSUE #4660] Fix updateBrokerConfig

tsunghanjacktsai commented on code in PR #4661:
URL: https://github.com/apache/rocketmq/pull/4661#discussion_r944066385


##########
common/src/main/java/org/apache/rocketmq/common/Configuration.java:
##########
@@ -219,6 +221,35 @@ public void persist() {
         }
     }
 
+    public void persistBrokerConf(Properties from) {
+        FileReader reader = null;
+        try {
+            readWriteLock.readLock().lockInterruptibly();
+            String fileName = this.getStorePath();
+            File file = new File(fileName);
+            if (!file.exists()) {
+                file.createNewFile();
+            }
+            Properties properties = new Properties();
+            reader = new FileReader(fileName);
+            properties.load(reader);
+            merge(from, properties);
+            final String str = MixAll.properties2String(properties);
+            MixAll.string2File(str, fileName);
+        } catch (Exception e) {
+            log.error("persist brokerConf error", e);
+        } finally {
+            readWriteLock.readLock().unlock();
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (IOException e) {
+                    log.error("Close FileReader occur error", e);

Review Comment:
   unable to close FileReader



-- 
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: dev-unsubscribe@rocketmq.apache.org

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