complone commented on code in PR #4661:
URL: https://github.com/apache/rocketmq/pull/4661#discussion_r965795257
##########
common/src/main/java/org/apache/rocketmq/common/Configuration.java:
##########
@@ -219,6 +224,35 @@ public void persist() {
}
}
+ public void persistBrokerConf(Properties from) {
+ BufferedReader reader = null;
+ try {
+ readWriteLock.readLock().lockInterruptibly();
Review Comment:
The following inline method already exists in getAllConfigsFormatString Is
it possible to take the relevant logic?
##########
common/src/main/java/org/apache/rocketmq/common/Configuration.java:
##########
@@ -219,6 +224,35 @@ public void persist() {
}
}
+ public void persistBrokerConf(Properties from) {
+ BufferedReader 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 BufferedReader(new InputStreamReader(new
FileInputStream(file), StandardCharsets.UTF_8));
+ 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);
Review Comment:
Maybe when an exception is thrown, we also need to close the reader?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]