Skip to content

Commit

Permalink
[ISSUE #8274] Optimize some codestyles and fix some warnings (#8275)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrhorse99 committed Jun 20, 2024
1 parent 4cedd07 commit 2091843
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,7 @@ private synchronized RemotingCommand updateAndCreateStaticTopic(ChannelHandlerCo
return response;
}
}
boolean force = false;
if (requestHeader.getForce() != null && requestHeader.getForce()) {
force = true;
}
boolean force = requestHeader.getForce() != null && requestHeader.getForce();

TopicConfig topicConfig = new TopicConfig(topic);
topicConfig.setReadQueueNums(requestHeader.getReadQueueNums());
Expand Down Expand Up @@ -945,13 +942,15 @@ private synchronized RemotingCommand updateColdDataFlowCtrGroupConfig(ChannelHan
Properties properties = MixAll.string2Properties(bodyStr);
if (properties != null) {
LOGGER.info("updateColdDataFlowCtrGroupConfig new config: {}, client: {}", properties, ctx.channel().remoteAddress());
properties.entrySet().stream().forEach(i -> {
properties.forEach((key, value) -> {
try {
String consumerGroup = String.valueOf(i.getKey());
Long threshold = Long.valueOf(String.valueOf(i.getValue()));
this.brokerController.getColdDataCgCtrService().addOrUpdateGroupConfig(consumerGroup, threshold);
String consumerGroup = String.valueOf(key);
Long threshold = Long.valueOf(String.valueOf(value));
this.brokerController.getColdDataCgCtrService()
.addOrUpdateGroupConfig(consumerGroup, threshold);
} catch (Exception e) {
LOGGER.error("updateColdDataFlowCtrGroupConfig properties on entry error, key: {}, val: {}", i.getKey(), i.getValue(), e);
LOGGER.error("updateColdDataFlowCtrGroupConfig properties on entry error, key: {}, val: {}",
key, value, e);
}
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package org.apache.rocketmq.broker.slave;

import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -85,12 +83,7 @@ private void syncTopicConfig() {
ConcurrentMap<String, TopicConfig> newTopicConfigTable = topicWrapper.getTopicConfigTable();
//delete
ConcurrentMap<String, TopicConfig> topicConfigTable = this.brokerController.getTopicConfigManager().getTopicConfigTable();
for (Iterator<Map.Entry<String, TopicConfig>> it = topicConfigTable.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, TopicConfig> item = it.next();
if (!newTopicConfigTable.containsKey(item.getKey())) {
it.remove();
}
}
topicConfigTable.entrySet().removeIf(item -> !newTopicConfigTable.containsKey(item.getKey()));
//update
topicConfigTable.putAll(newTopicConfigTable);

Expand All @@ -104,12 +97,7 @@ private void syncTopicConfig() {
ConcurrentMap<String, TopicConfig> newTopicConfigTable = topicWrapper.getTopicConfigTable();
//delete
ConcurrentMap<String, TopicConfig> topicConfigTable = this.brokerController.getTopicConfigManager().getTopicConfigTable();
for (Iterator<Map.Entry<String, TopicConfig>> it = topicConfigTable.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, TopicConfig> item = it.next();
if (!newTopicConfigTable.containsKey(item.getKey())) {
it.remove();
}
}
topicConfigTable.entrySet().removeIf(item -> !newTopicConfigTable.containsKey(item.getKey()));
//update
topicConfigTable.putAll(newTopicConfigTable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void getAllAclFiles(String path) {
return;
}
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
for (int i = 0; files != null && i < files.length; i++) {
String fileName = files[i].getAbsolutePath();
File f = new File(fileName);
if (fileName.equals(aclPath + File.separator + "tools.yml")) {
Expand Down

0 comments on commit 2091843

Please sign in to comment.