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 49fef306 fix: fail explicitly when client provider is missing (#697)
49fef306 is described below

commit 49fef306b491de3101e3d73c0ac8873dbc51207d
Author: aias00 <[email protected]>
AuthorDate: Sun Aug 2 20:09:25 2026 -0700

    fix: fail explicitly when client provider is missing (#697)
---
 .../studio/cluster/client/ClientProviderStub.java  | 52 ++--------------------
 .../cluster/client/ClientProviderStubTest.java     | 39 ++++++++++++++++
 2 files changed, 43 insertions(+), 48 deletions(-)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/cluster/client/ClientProviderStub.java
 
b/server/src/main/java/org/apache/rocketmq/studio/cluster/client/ClientProviderStub.java
index a8a1a9f9..f399226f 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/cluster/client/ClientProviderStub.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/cluster/client/ClientProviderStub.java
@@ -16,64 +16,20 @@
  */
 package org.apache.rocketmq.studio.cluster.client;
 
-import org.apache.rocketmq.studio.common.domain.enums.ClientLanguage;
-import org.apache.rocketmq.studio.common.domain.enums.ClientType;
-import org.apache.rocketmq.studio.common.domain.enums.Protocol;
+import org.apache.rocketmq.studio.common.exception.BusinessException;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
-import java.time.LocalDateTime;
-import java.util.Arrays;
 import java.util.List;
-import java.util.stream.Collectors;
 
 @Slf4j
 @Component
 public class ClientProviderStub implements ClientProvider {
 
-    private final List<ClientConnectionVO> stubData = Arrays.asList(
-            ClientConnectionVO.builder()
-                    .clientId("producer-001")
-                    .type(ClientType.Producer)
-                    .groupOrTopic("order-topic")
-                    .producerGroup("pg-order")
-                    .protocol(Protocol.gRPC)
-                    .address("192.168.1.10:56789")
-                    .language(ClientLanguage.Java)
-                    .version("5.1.0")
-                    .connectedAt(LocalDateTime.now().minusHours(2))
-                    .clusterName("production-cluster")
-                    .build(),
-            ClientConnectionVO.builder()
-                    .clientId("consumer-001")
-                    .type(ClientType.Consumer)
-                    .groupOrTopic("order-consumer-group")
-                    .protocol(Protocol.gRPC)
-                    .address("192.168.1.11:56790")
-                    .language(ClientLanguage.Java)
-                    .version("5.1.0")
-                    .connectedAt(LocalDateTime.now().minusHours(1))
-                    .clusterName("production-cluster")
-                    .build(),
-            ClientConnectionVO.builder()
-                    .clientId("consumer-002")
-                    .type(ClientType.Consumer)
-                    .groupOrTopic("payment-consumer-group")
-                    .protocol(Protocol.Remoting)
-                    .address("192.168.1.12:56791")
-                    .language(ClientLanguage.Go)
-                    .version("5.0.0")
-                    .connectedAt(LocalDateTime.now().minusMinutes(30))
-                    .clusterName("staging-cluster")
-                    .build()
-    );
-
     @Override
     public List<ClientConnectionVO> findConnections(String clusterId, String 
type) {
-        log.debug("Stub: finding connections, clusterId={}, type={}", 
clusterId, type);
-        return stubData.stream()
-                .filter(c -> clusterId == null || 
clusterId.equals(c.getClusterName()))
-                .filter(c -> type == null || 
type.equalsIgnoreCase(c.getType().name()))
-                .collect(Collectors.toList());
+        log.warn("ClientProviderStub.findConnections called without a real 
client provider. clusterId={}, type={}",
+                clusterId, type);
+        throw new BusinessException(501, "Client connection provider is not 
configured");
     }
 }
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/client/ClientProviderStubTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/client/ClientProviderStubTest.java
new file mode 100644
index 00000000..6ee00471
--- /dev/null
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/client/ClientProviderStubTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.cluster.client;
+
+import org.apache.rocketmq.studio.common.exception.BusinessException;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class ClientProviderStubTest {
+
+    private final ClientProviderStub provider = new ClientProviderStub();
+
+    @Test
+    void findConnectionsShouldFailWhenRealProviderIsMissing() {
+        assertThatThrownBy(() -> 
provider.findConnections("production-cluster", "Producer"))
+                .isInstanceOf(BusinessException.class)
+                .hasMessage("Client connection provider is not configured")
+                .satisfies(ex -> assertThatBusinessExceptionCode(ex, 501));
+    }
+
+    private void assertThatBusinessExceptionCode(Throwable ex, int code) {
+        org.assertj.core.api.Assertions.assertThat(((BusinessException) 
ex).getCode()).isEqualTo(code);
+    }
+}

Reply via email to