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 095ec328 fix(lite-topic): handle unset consumed message count (#1492)
095ec328 is described below

commit 095ec32845c19f3f4ecdc0ae2f23503ec14e781b
Author: yyqdbngt <[email protected]>
AuthorDate: Tue Aug 11 17:50:26 2026 +0800

    fix(lite-topic): handle unset consumed message count (#1492)
    
    Co-authored-by: yyqdbngt <[email protected]>
---
 .../rocketmq/studio/model/LiteTopicSession.java    |  4 +--
 .../studio/model/LiteTopicSessionTest.java         | 41 ++++++++++++++++++++++
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicSession.java 
b/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicSession.java
index debbb8f4..ce6fe56f 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicSession.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicSession.java
@@ -72,7 +72,7 @@ public class LiteTopicSession {
     }
 
     public double getConsumptionProgress() {
-        if (totalMessages == null || totalMessages == 0) {
+        if (totalMessages == null || totalMessages == 0 || consumedMessages == 
null) {
             return 0.0;
         }
         return (double) consumedMessages / totalMessages * 100.0;
@@ -87,4 +87,4 @@ public class LiteTopicSession {
         private Integer popCheckpoint;
         private Integer totalPopCount;
     }
-}
\ No newline at end of file
+}
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/model/LiteTopicSessionTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/model/LiteTopicSessionTest.java
new file mode 100644
index 00000000..9a6a2ffb
--- /dev/null
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/model/LiteTopicSessionTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rocketmq.studio.model;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class LiteTopicSessionTest {
+
+    @Test
+    void consumptionProgressShouldHandleUnsetConsumedMessages() {
+        LiteTopicSession session = new LiteTopicSession();
+        session.setTotalMessages(10L);
+
+        assertThat(session.getConsumptionProgress()).isZero();
+    }
+
+    @Test
+    void consumptionProgressShouldCalculatePercentage() {
+        LiteTopicSession session = new LiteTopicSession();
+        session.setTotalMessages(10L);
+        session.setConsumedMessages(4L);
+
+        assertThat(session.getConsumptionProgress()).isEqualTo(40.0);
+    }
+}

Reply via email to