This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new be5472544 fix(cluster): skip address-less brokers in config scan 
(#5769)
be5472544 is described below

commit be547254477510fda0155007b0a2de314ac9fcbb
Author: 0 <[email protected]>
AuthorDate: Mon Oct 19 18:39:54 2026 +0800

    fix(cluster): skip address-less brokers in config scan (#5769)
    
    Verified against `rocketmq-studio` at b88aedc34 before merging: 
缺陷仍在(`cluster/broker/ClusterService.java:323` 仍是 `new 
java.util.TreeMap<>()`,`:327` `configs.put(broker.getAddr(), ...)` 无守卫;同族守卫仍在 
`:235`、`:281`、`:50
    
    merge-tree clean against the current trunk. Merged as-is (squash) per the 
maintainer review of 2026-10-19.
---
 .../rocketmq/studio/cluster/broker/ClusterService.java   |  6 ++++++
 .../studio/cluster/broker/ClusterServiceTest.java        | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterService.java
 
b/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterService.java
index 19ccafa6f..45ff1039e 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterService.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterService.java
@@ -324,6 +324,12 @@ public class ClusterService {
         ClusterVO cluster = requireSingleCluster(instanceId);
         if (cluster.getBrokers() != null) {
             for (BrokerVO broker : cluster.getBrokers()) {
+                // A discovered broker can lack an address (e.g. a slave-only 
broker whose
+                // master is down). Skip it like the config update does 
instead of failing
+                // the whole per-broker config scan on a null map key.
+                if (broker == null || broker.getAddr() == null || 
broker.getAddr().isEmpty()) {
+                    continue;
+                }
                 configs.put(broker.getAddr(), 
brokerConfigService.getBrokerConfig(broker.getAddr(), instanceId));
             }
         }
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterServiceTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterServiceTest.java
index 56a50744c..53b92463f 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterServiceTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterServiceTest.java
@@ -818,6 +818,22 @@ class ClusterServiceTest {
         verify(clusterProvider, never()).refreshClusterDetail(any(), any());
     }
 
+    @Test
+    void readBrokerConfigsSkipsBrokersWithoutAnAddress() {
+        // A slave-only broker whose master is down is discovered with no 
address; the config
+        // scan must skip it (like the config update does) instead of failing 
on a null key.
+        sampleCluster.setId("DefaultCluster");
+        sampleCluster.setBrokers(List.of(
+                BrokerVO.builder().name("broker-no-addr").build(),
+                
BrokerVO.builder().name("broker-0").addr("10.0.0.1:10911").build()));
+        
when(clusterProvider.discoverClusters("prod-apache")).thenReturn(List.of(sampleCluster));
+        when(brokerConfigService.getBrokerConfig("10.0.0.1:10911", 
"prod-apache"))
+                .thenReturn(sampleCluster.getConfig());
+
+        assertThat(clusterService.readBrokerConfigs("prod-apache"))
+                .containsOnlyKeys("10.0.0.1:10911");
+    }
+
     @Test
     void instanceConfigPreviewUsesTheSameDiscoveredCluster() {
         sampleCluster.setId("DefaultCluster");

Reply via email to