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 f1a50c7e fix(model): guard lite topic quota null fields (#1154)
f1a50c7e is described below
commit f1a50c7e4871067b13e4f629c452b4e9fb9624f8
Author: 0 <[email protected]>
AuthorDate: Fri Aug 7 16:13:23 2026 +0800
fix(model): guard lite topic quota null fields (#1154)
---
.../rocketmq/studio/model/LiteTopicQuota.java | 4 ++-
.../rocketmq/studio/model/LiteTopicQuotaTest.java | 35 ++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git
a/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicQuota.java
b/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicQuota.java
index 39fd47ab..7c414cf4 100644
--- a/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicQuota.java
+++ b/server/src/main/java/org/apache/rocketmq/studio/model/LiteTopicQuota.java
@@ -56,7 +56,9 @@ public class LiteTopicQuota {
}
public boolean isQuotaExceeded() {
- return currentTopicCount >= maxTopicCount;
+ // Guard against unset fields, mirroring getUsageRate; an unconfigured
max is not exceeded.
+ return maxTopicCount != null && currentTopicCount != null
+ && currentTopicCount >= maxTopicCount;
}
public Integer getRemainingQuota() {
diff --git
a/server/src/test/java/org/apache/rocketmq/studio/model/LiteTopicQuotaTest.java
b/server/src/test/java/org/apache/rocketmq/studio/model/LiteTopicQuotaTest.java
new file mode 100644
index 00000000..14043ea8
--- /dev/null
+++
b/server/src/test/java/org/apache/rocketmq/studio/model/LiteTopicQuotaTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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
+ */
+package org.apache.rocketmq.studio.model;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class LiteTopicQuotaTest {
+
+ @Test
+ void quotaShouldNotBeExceededWhenMaxIsUnset() {
+ LiteTopicQuota quota = new LiteTopicQuota();
+ quota.setCurrentTopicCount(10);
+
+ assertThat(quota.isQuotaExceeded()).isFalse();
+ }
+
+ @Test
+ void quotaShouldBeExceededWhenCurrentReachesMax() {
+ LiteTopicQuota quota = new LiteTopicQuota();
+ quota.setMaxTopicCount(10);
+ quota.setCurrentTopicCount(10);
+
+ assertThat(quota.isQuotaExceeded()).isTrue();
+ }
+}