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 976a1974c fix(cluster): stop serializing undocumented cluster 
bookkeeping fields (#6930)
976a1974c is described below

commit 976a1974c7aacf558bd6218bd93f0b8057ad9551
Author: Chstercc <[email protected]>
AuthorDate: Fri Nov 27 11:53:26 2026 +0800

    fix(cluster): stop serializing undocumented cluster bookkeeping fields 
(#6930)
---
 .../rocketmq/studio/cluster/broker/ClusterVO.java  |  5 +++++
 .../cluster/broker/ClusterControllerTest.java      | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterVO.java 
b/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterVO.java
index a1f419636..4b85de579 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterVO.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterVO.java
@@ -16,6 +16,7 @@
  */
 package org.apache.rocketmq.studio.cluster.broker;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import org.apache.rocketmq.studio.cluster.config.ClusterConfigVO;
 import org.apache.rocketmq.studio.cluster.nameserver.NameServerVO;
 import org.apache.rocketmq.studio.cluster.proxy.ProxyVO;
@@ -41,7 +42,11 @@ import java.util.List;
 @AllArgsConstructor
 public class ClusterVO {
     private String id;
+    // Bookkeeping columns left over from the persisted-entity shape. Clusters 
are discovered
+    // from the NameServer, so nothing fills them and ClusterInfo does not 
declare them.
+    @JsonIgnore
     private LocalDateTime gmtCreate;
+    @JsonIgnore
     private LocalDateTime gmtModified;
     private String name;
     private String nsClusterName;
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterControllerTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterControllerTest.java
index 1e9cb6fd5..f3ad000d1 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterControllerTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/broker/ClusterControllerTest.java
@@ -27,6 +27,7 @@ import 
org.apache.rocketmq.studio.cluster.config.ClusterConfigPreviewVO;
 import org.apache.rocketmq.studio.cluster.config.ClusterConfigVO;
 import org.apache.rocketmq.studio.cluster.config.UpdateConfigDTO;
 
+import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.apache.rocketmq.studio.common.domain.enums.ClusterStatus;
@@ -42,11 +43,13 @@ import 
org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
 import org.springframework.test.context.bean.override.mockito.MockitoBean;
 import org.springframework.http.MediaType;
 import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
 
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.stream.Stream;
 
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.Mockito.verify;
@@ -159,6 +162,25 @@ class ClusterControllerTest extends WebMvcAuthTestSupport {
                 
.andExpect(jsonPath("$.data[1].name").value("staging-cluster"));
     }
 
+    @Test
+    void listClustersShouldNotSerializeFieldsOutsideTheContractTest() throws 
Exception {
+        
when(clusterService.listClusters(isNull())).thenReturn(Collections.singletonList(
+                buildCluster("cluster-1", "production-cluster", 
ClusterStatus.healthy)));
+
+        MvcResult result = mockMvc.perform(get("/api/clusters"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data[0].id").value("cluster-1"))
+                .andReturn();
+
+        JsonNode cluster = objectMapper
+                .readTree(result.getResponse().getContentAsString())
+                .path("data").path(0);
+        // ClusterInfo in docs/api-spec.md has neither field, and nothing 
fills them:
+        // a cluster is discovered from the NameServer, not read from a 
registry row.
+        assertFalse(cluster.has("gmtCreate"), "gmtCreate is not part of the 
ClusterInfo contract");
+        assertFalse(cluster.has("gmtModified"), "gmtModified is not part of 
the ClusterInfo contract");
+    }
+
     @Test
     void listClustersShouldReturnEmptyArrayWhenNoClusters() throws Exception {
         
when(clusterService.listClusters(isNull())).thenReturn(Collections.emptyList());

Reply via email to