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 2022/08/26 06:17:16 UTC
[rocketmq] branch fix_npe created (now e3ef68cb6)
This is an automated email from the ASF dual-hosted git repository.
jinrongtong pushed a change to branch fix_npe
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
at e3ef68cb6 Fix NPE in CommandUtil
This branch includes the following new commits:
new e3ef68cb6 Fix NPE in CommandUtil
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[rocketmq] 01/01: Fix NPE in CommandUtil
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jinrongtong pushed a commit to branch fix_npe
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
commit e3ef68cb6f315c1dd1a75309252b3948bca6156b
Author: RongtongJin <ji...@mails.ucas.ac.cn>
AuthorDate: Fri Aug 26 14:16:56 2022 +0800
Fix NPE in CommandUtil
---
.../main/java/org/apache/rocketmq/tools/command/CommandUtil.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java b/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
index b7faee32d..0ff4f3f91 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
@@ -138,17 +138,20 @@ public class CommandUtil {
public static Set<String> fetchMasterAndSlaveAddrByBrokerName(final MQAdminExt adminExt, final String brokerName)
throws InterruptedException, RemotingConnectException, RemotingTimeoutException,
RemotingSendRequestException, MQBrokerException {
+ Set<String> brokerAddressSet = new HashSet<>();
ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
final BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
- return new HashSet<>(brokerData.getBrokerAddrs().values());
+ if (brokerData != null) {
+ brokerAddressSet.addAll(brokerData.getBrokerAddrs().values());
+ }
+ return brokerAddressSet;
}
-
public static Set<String> fetchBrokerNameByClusterName(final MQAdminExt adminExt, final String clusterName)
throws Exception {
ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);
- if (brokerNameSet.isEmpty()) {
+ if (brokerNameSet == null || brokerNameSet.isEmpty()) {
throw new Exception(ERROR_MESSAGE);
}
return brokerNameSet;