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 c7193109e fix(group): allow zero retry settings on update (#4123)
c7193109e is described below
commit c7193109e26c29f2f46bc514d23e58b4e6b12c80
Author: Zhao Jianing <[email protected]>
AuthorDate: Wed Sep 9 20:58:36 2026 +0800
fix(group): allow zero retry settings on update (#4123)
`UpdateConsumerGroupSettingsDTO` validated `retryQueueNums` and
`retryMaxTimes` with `@Positive`, so sending 0 was rejected with a 400 before
the request ever reached `MetadataService`. The create DTO for the same two
fields uses `@PositiveOrZero`, so the update path was stricter than the create
path for no stated reason.
Zero is a legitimate broker value here and the update path does apply it —
`RocketMQAdminClientImpl` writes both straight through with
`config.setRetryQueueNums(...)` / `config.setRetryMaxTimes(...)`. Blocking it
at the bean-validation layer meant an operator could create a group with zero
retries but could not later set an existing group back to zero. Both fields now
use `@PositiveOrZero`, with the messages updated to match; negative values are
still rejected.
Note the motivation recorded in the original PR description is not the one
that holds up: the scenario it describes cannot be reproduced, because the
group-creation path in `RocketMQAdminClientImpl` hardcodes `retryQueueNums` to
1 and clamps a zero `retryMaxTimes` to 16. The asymmetry against the create DTO
and the fact that the update path applies the value are what make this worth
fixing.
---
.../group/UpdateConsumerGroupSettingsDTO.java | 6 +--
.../group/UpdateConsumerGroupSettingsDTOTest.java | 56 ++++++++++++++++++++++
2 files changed, 59 insertions(+), 3 deletions(-)
diff --git
a/server/src/main/java/org/apache/rocketmq/studio/instance/group/UpdateConsumerGroupSettingsDTO.java
b/server/src/main/java/org/apache/rocketmq/studio/instance/group/UpdateConsumerGroupSettingsDTO.java
index 56036204d..21afd2797 100644
---
a/server/src/main/java/org/apache/rocketmq/studio/instance/group/UpdateConsumerGroupSettingsDTO.java
+++
b/server/src/main/java/org/apache/rocketmq/studio/instance/group/UpdateConsumerGroupSettingsDTO.java
@@ -18,7 +18,7 @@ package org.apache.rocketmq.studio.instance.group;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
-import jakarta.validation.constraints.Positive;
+import jakarta.validation.constraints.PositiveOrZero;
import lombok.Data;
@Data
@@ -28,10 +28,10 @@ public class UpdateConsumerGroupSettingsDTO {
@NotBlank(message = "name is required")
private String name;
@NotNull(message = "retryQueueNums is required")
- @Positive(message = "retryQueueNums must be positive")
+ @PositiveOrZero(message = "retryQueueNums must be zero or positive")
private Integer retryQueueNums;
@NotNull(message = "retryMaxTimes is required")
- @Positive(message = "retryMaxTimes must be positive")
+ @PositiveOrZero(message = "retryMaxTimes must be zero or positive")
private Integer retryMaxTimes;
private Boolean consumeEnable;
private Boolean consumeMessageOrderly;
diff --git
a/server/src/test/java/org/apache/rocketmq/studio/instance/group/UpdateConsumerGroupSettingsDTOTest.java
b/server/src/test/java/org/apache/rocketmq/studio/instance/group/UpdateConsumerGroupSettingsDTOTest.java
new file mode 100644
index 000000000..53e2a2a20
--- /dev/null
+++
b/server/src/test/java/org/apache/rocketmq/studio/instance/group/UpdateConsumerGroupSettingsDTOTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.instance.group;
+
+import jakarta.validation.Validation;
+import jakarta.validation.Validator;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class UpdateConsumerGroupSettingsDTOTest {
+
+ private final Validator validator =
Validation.buildDefaultValidatorFactory().getValidator();
+
+ @Test
+ void shouldAcceptZeroRetrySettingsTest() {
+ // 0 is a valid broker-side value (retryQueueNums=0 disables retry
queues,
+ // retryMaxTimes=0 sends failures straight to the DLQ) and
CreateConsumerGroupDTO
+ // accepts retryMaxTimes=0 — the update path must not reject what
create allows.
+ UpdateConsumerGroupSettingsDTO request = new
UpdateConsumerGroupSettingsDTO();
+ request.setInstanceId("instance-a");
+ request.setName("cg-orders");
+ request.setRetryQueueNums(0);
+ request.setRetryMaxTimes(0);
+
+ assertThat(validator.validate(request)).isEmpty();
+ }
+
+ @Test
+ void shouldRejectNegativeRetrySettingsTest() {
+ UpdateConsumerGroupSettingsDTO request = new
UpdateConsumerGroupSettingsDTO();
+ request.setInstanceId("instance-a");
+ request.setName("cg-orders");
+ request.setRetryQueueNums(-1);
+ request.setRetryMaxTimes(-1);
+
+ assertThat(validator.validate(request))
+ .extracting(violation -> violation.getMessage())
+ .containsExactlyInAnyOrder("retryQueueNums must be zero or
positive",
+ "retryMaxTimes must be zero or positive");
+ }
+}