Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ public Map<String, List<String>> jsonDataFile2map(File file) {
for (String string : strings) {
sb.append(string);
}
JSONObject json = (JSONObject) JSONObject.parse(sb.toString());
Object parsed = JSONObject.parse(sb.toString());
if (parsed == null) {
log.warn("No valid dashboard data in file: {}", file.getAbsolutePath());
return Maps.newHashMap();
}
JSONObject json = (JSONObject) parsed;
Set<Map.Entry<String, Object>> entries = json.entrySet();
Map<String, List<String>> map = Maps.newHashMap();
for (Map.Entry<String, Object> entry : entries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.topic.TopicValidator;
import org.apache.rocketmq.dashboard.config.RMQConfigure;
import org.apache.rocketmq.dashboard.exception.ServiceException;
import org.apache.rocketmq.dashboard.model.request.SendTopicMessageRequest;
import org.apache.rocketmq.dashboard.model.request.TopicConfigInfo;
import org.apache.rocketmq.dashboard.model.request.TopicTypeList;
Expand Down Expand Up @@ -380,6 +381,9 @@ private TopicList getSystemTopicList() {
@Override
public SendResult sendTopicMessageRequest(SendTopicMessageRequest sendTopicMessageRequest) {
List<TopicConfigInfo> topicConfigInfos = examineTopicConfig(sendTopicMessageRequest.getTopic());
if (topicConfigInfos.isEmpty()) {
throw new ServiceException(-1, String.format("Topic [%s] has no broker route, cannot send message", sendTopicMessageRequest.getTopic()));
}
String messageType = topicConfigInfos.get(0).getMessageType();
AclClientRPCHook rpcHook = null;
if (configure.isACLEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ public void load(InputStream inputStream) {
} else if (arrs.length == 1) {
role = 0;
} else {
role = Integer.parseInt(arrs[1].trim());
try {
role = Integer.parseInt(arrs[1].trim());
} catch (NumberFormatException e) {
log.error("Invalid role '{}' for user '{}', defaulting to normal user", arrs[1].trim(), key);
role = 0;
}
}

loadUserMap.put(key, new User(key, arrs[0].trim(), role));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ public void collectBroker() {
if (kvTable == null) {
continue;
}
String[] tpsArray = kvTable.getTable().get("getTotalTps").split(" ");
String totalTpsStr = kvTable.getTable().get("getTotalTps");
if (totalTpsStr == null || totalTpsStr.trim().isEmpty()) {
continue;
}
String[] tpsArray = totalTpsStr.trim().split(" ");
BigDecimal totalTps = new BigDecimal(0);
for (String tps : tpsArray) {
totalTps = totalTps.add(new BigDecimal(tps));
Expand Down