This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new fa4faaf72 fix(tencent): reject an incomplete topic consumer page
(#6076)
fa4faaf72 is described below
commit fa4faaf72550401ed4d1dbc98b47b1e037d7a314
Author: Apulupie <[email protected]>
AuthorDate: Fri Nov 27 12:56:12 2026 +0800
fix(tencent): reject an incomplete topic consumer page (#6076)
---
.../studio/provider/tencent/TencentInstanceProvider.java | 15 ++++++++++-----
.../provider/tencent/TencentInstanceProviderTest.java | 12 ++++++++++++
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git
a/server/src/main/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProvider.java
b/server/src/main/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProvider.java
index 801d00a7a..b67955def 100644
---
a/server/src/main/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProvider.java
+++
b/server/src/main/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProvider.java
@@ -416,25 +416,30 @@ public class TencentInstanceProvider implements
InstanceProvider {
List<TopicConsumerVO> consumers = new ArrayList<>();
long fetchedSubscriptions = 0L;
for (int page = 0; page < MAX_PAGES; page++) {
+ long offset = (long) page * CONSUMER_PAGE_SIZE;
DescribeTopicRequest request = new DescribeTopicRequest();
request.setInstanceId(context.cloudInstanceId());
request.setTopic(topicName);
- request.setOffset((long) page * CONSUMER_PAGE_SIZE);
+ request.setOffset(offset);
request.setLimit((long) CONSUMER_PAGE_SIZE);
DescribeTopicResponse response =
clientFactory.call(context.credentialId(), context.regionId(),
client -> client.DescribeTopic(request));
SubscriptionData[] data = response == null ? null :
response.getSubscriptionData();
- if (data == null || data.length == 0) {
+ Long subscriptionCount = response == null ? null :
response.getSubscriptionCount();
+ int returned = data == null ? 0 : data.length;
+ // DescribeTopic pages with CONSUMER_PAGE_SIZE, which matches the
PAGE_SIZE the shared
+ // completeness guard compares against.
+ requireCompletePage("topic consumer", offset, returned,
subscriptionCount);
+ if (returned == 0) {
break;
}
- fetchedSubscriptions += data.length;
+ fetchedSubscriptions += returned;
for (SubscriptionData subscription : data) {
if (subscription != null) {
consumers.add(toTopicConsumer(subscription));
}
}
- Long subscriptionCount = response.getSubscriptionCount();
- if (data.length < CONSUMER_PAGE_SIZE
+ if (returned < CONSUMER_PAGE_SIZE
|| subscriptionCount != null && fetchedSubscriptions >=
subscriptionCount) {
break;
}
diff --git
a/server/src/test/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProviderTest.java
b/server/src/test/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProviderTest.java
index 8c63f7141..a367df8ac 100644
---
a/server/src/test/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProviderTest.java
+++
b/server/src/test/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProviderTest.java
@@ -673,6 +673,18 @@ class TencentInstanceProviderTest {
.containsOnly(100L);
}
+ @Test
+ void
getTopicConsumersShouldRejectIncompletePageWhenSubscriptionCountRequiresMoreTest()
throws Exception {
+ DescribeTopicResponse response = new DescribeTopicResponse();
+ response.setSubscriptionCount(2L);
+ response.setSubscriptionData(new
SubscriptionData[]{subscription("GID_partial")});
+ when(client.DescribeTopic(any())).thenReturn(response);
+
+ assertThatThrownBy(() ->
provider.getTopicConsumers(STUDIO_INSTANCE_ID, "orders"))
+ .isInstanceOf(BusinessException.class)
+ .satisfies(error -> assertThat(((BusinessException)
error).getCode()).isEqualTo(502));
+ }
+
@Test
void
listConsumerGroupsShouldRejectIncompletePageWhenTotalCountRequiresMoreTest()
throws Exception {
ConsumeGroupItem item = new ConsumeGroupItem();