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 2e5dcae2 fix(lite-topic): handle unset summary consumer count (#1493)
2e5dcae2 is described below

commit 2e5dcae22f225b23a8eae9cd4f5f028560972385
Author: yyqdbngt <[email protected]>
AuthorDate: Tue Aug 11 17:50:48 2026 +0800

    fix(lite-topic): handle unset summary consumer count (#1493)
    
    Co-authored-by: yyqdbngt <[email protected]>
---
 .../java/org/apache/rocketmq/studio/model/LiteTopicSummary.java  | 7 ++++---
 .../org/apache/rocketmq/studio/model/LiteTopicSummaryTest.java   | 9 +++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicSummary.java 
b/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicSummary.java
index 94507d7c..3470d3db 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicSummary.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicSummary.java
@@ -67,13 +67,14 @@ public class LiteTopicSummary {
     }
 
     public double getConsumerDensity() {
-        if (topicCount == null || topicCount == 0) {
+        if (topicCount == null || topicCount == 0 || consumerCount == null) {
             return 0.0;
         }
         return (double) consumerCount / topicCount;
     }
 
     public boolean isEmptyAggregation() {
-        return consumerCount == 0 && (totalBacklog == null || totalBacklog == 
0);
+        return (consumerCount == null || consumerCount == 0)
+                && (totalBacklog == null || totalBacklog == 0);
     }
-}
\ No newline at end of file
+}
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/model/LiteTopicSummaryTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/model/LiteTopicSummaryTest.java
index f6841418..cf7fbf0e 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/model/LiteTopicSummaryTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/model/LiteTopicSummaryTest.java
@@ -43,4 +43,13 @@ class LiteTopicSummaryTest {
 
         assertThat(summary.getTTLStatus()).isEqualTo("ACTIVE");
     }
+
+    @Test
+    void aggregationHelpersShouldHandleUnsetConsumerCount() {
+        LiteTopicSummary summary = new LiteTopicSummary();
+        summary.setTopicCount(5);
+
+        assertThat(summary.getConsumerDensity()).isZero();
+        assertThat(summary.isEmptyAggregation()).isTrue();
+    }
 }

Reply via email to