iloveeyjafjalla opened a new pull request, #6859:
URL: https://github.com/apache/rocketmq-dashboard/pull/6859

   ## Which Issue(s) This PR Fixes
   
   Fixes #6858
   
   ## Problem / Evidence
   
   `GET /api/dashboard?instanceId=local-broker` answered `totalTopics: 32` 
(`clusters[0].topics: 32`) for a cluster that holds 30 user topics, because the 
overview counts the two topics the broker creates for its own cluster:
   
   ```
   $ mqadmin topicList -n rmq-nameserver:9876     # 46 names, including:
   DefaultCluster                16 read / 16 write
   DefaultCluster_REPLY_TOPIC     1 read /  1 write
   ```
   
   `TopicConfigManager#init` creates both at broker start and registers each 
with `TopicValidator.addSystemTopic`, but that set is per JVM - Studio never 
inherits it, so `SystemTopicFilter` (which delegates to 
`TopicValidator.isSystemTopic`) hands both back as user topics. The console 
already carried this registration once, for the same statistics (#82 / #83).
   
   ## Fix
   
   `SystemTopicFilter` gains the cluster-aware overload and the counting path 
passes the owning cluster:
   
   ```java
   public static boolean isSystem(String topicName, Set<String> brokerNames, 
String clusterName) {
       if (isSystem(topicName, brokerNames)) {
           return true;
       }
       if (clusterName == null || clusterName.isEmpty()) {
           return false;
       }
       return clusterName.equals(topicName) || 
MixAll.getReplyTopic(clusterName).equals(topicName);
   }
   ```
   
   Only the owning cluster's two names match: a user topic that merely ends in 
the reply suffix, or carries another cluster's name, stays a user topic. The 
base overload is unchanged, so every other caller keeps its behaviour.
   
   ## Tests
   
   `SystemTopicFilterTest` gains the cluster cases; before the change the new 
case fails:
   
   ```
   
SystemTopicFilterTest.shouldRecognizeTheTopicsTheBrokerGeneratesForItsOwnClusterTest
 -- <<< FAILURE!
     Expecting value to be true but was false
   Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
   ```
   
   After the change, the filter suite plus every provider suite that counts or 
lists topics:
   
   ```
   Tests run: 156, Failures: 0, Errors: 0, Skipped: 0
     (RocketMQDLQProviderTest 60, RocketMQMetadataProviderTest 54, 
RocketMQDashboardProviderTest 39, SystemTopicFilterTest 2, 
SystemGroupFilterTest 1)
   ```
   
   ## End-to-end verification
   
   Same stack, same instance, patched build started beside the running one 
(`SERVER_PORT=8890`, same database, same brokers):
   
   ```
   8888 (unpatched)  totalTopics: 32   clusters[0].topics: 32
   8890 (patched)    totalTopics: 30   clusters[0].topics: 30
   ```
   
   The two removed topics are exactly `DefaultCluster` and 
`DefaultCluster_REPLY_TOPIC`; the remaining 30 are the studio's inventory 
topics that exist on that broker. The change was prepared with AI assistance 
and reviewed, tested and verified by me.
   


-- 
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]

Reply via email to