This is an automated email from the ASF dual-hosted git repository.

Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 7d772ff1a1 fix(admin): copy the namespace id in 
DiscoveryTransfer.mapToDTO (#7389)
7d772ff1a1 is described below

commit 7d772ff1a1dd1294b301228e0b5a317f573c8ae6
Author: Sean-Walker0 <[email protected]>
AuthorDate: Wed Oct 14 09:34:34 2026 +0800

    fix(admin): copy the namespace id in DiscoveryTransfer.mapToDTO (#7389)
    
    * fix(admin): copy the namespace id in DiscoveryTransfer.mapToDTO
    
    DiscoveryTransfer#mapToDTO(DiscoveryDO) builds DiscoveryDTO for every
    caller without copying namespaceId even though both DiscoveryDO and
    DiscoveryDTO carry the field, so the DiscoveryDTO embedded in the
    proxy selector pageList/listAllData responses always reports a null
    namespace for a namespaced discovery. The sibling mapToVo overloads
    copy all shared fields; this one missed the namespace.
    
    The new DiscoveryTransferTest covers both directions: with a
    namespace id (fails on current master with expected <ns-1> but was
    <null>) and without one (unchanged null).
    
    Verified with ./mvnw test -pl shenyu-admin -am and
    ./mvnw checkstyle:check -pl shenyu-admin (module-scoped).
    
    * ci: retrigger checks (e2e family hit the known httpbin/cluster flakes)
    
    * ci: retrigger the flaky integrated-test jobs (kind node not-ready / rule 
sync timing)
    
    ---------
    
    Co-authored-by: Sean-Walker0 
<[email protected]>
---
 .../shenyu/admin/transfer/DiscoveryTransfer.java   |  1 +
 .../admin/transfer/DiscoveryTransferTest.java      | 57 ++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java
index 5ba4bb9903..fc8fea656c 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java
@@ -159,6 +159,7 @@ public enum DiscoveryTransfer {
             discoveryDTO.setServerList(data.getServerList());
             discoveryDTO.setPluginName(data.getPluginName());
             discoveryDTO.setProps(data.getProps());
+            discoveryDTO.setNamespaceId(data.getNamespaceId());
             return discoveryDTO;
         }).orElse(null);
     }
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/transfer/DiscoveryTransferTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/transfer/DiscoveryTransferTest.java
new file mode 100644
index 0000000000..32c214d094
--- /dev/null
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/transfer/DiscoveryTransferTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.shenyu.admin.transfer;
+
+import org.apache.shenyu.admin.model.dto.DiscoveryDTO;
+import org.apache.shenyu.admin.model.entity.DiscoveryDO;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Test cases for DiscoveryTransfer.
+ */
+public final class DiscoveryTransferTest {
+
+    @Test
+    public void testMapToDTOKeepsNamespaceId() {
+        DiscoveryDO discoveryDO = new DiscoveryDO();
+        discoveryDO.setId("1");
+        discoveryDO.setDiscoveryName("prod-registry");
+        discoveryDO.setDiscoveryType("zookeeper");
+        discoveryDO.setNamespaceId("ns-1");
+
+        DiscoveryDTO discoveryDTO = 
DiscoveryTransfer.INSTANCE.mapToDTO(discoveryDO);
+
+        assertEquals("ns-1", discoveryDTO.getNamespaceId());
+        assertEquals("prod-registry", discoveryDTO.getName());
+        assertEquals("zookeeper", discoveryDTO.getType());
+    }
+
+    @Test
+    public void testMapToDTOWithoutNamespaceId() {
+        DiscoveryDO discoveryDO = new DiscoveryDO();
+        discoveryDO.setId("1");
+        discoveryDO.setDiscoveryName("prod-registry");
+        discoveryDO.setDiscoveryType("zookeeper");
+
+        DiscoveryDTO discoveryDTO = 
DiscoveryTransfer.INSTANCE.mapToDTO(discoveryDO);
+
+        assertEquals(null, discoveryDTO.getNamespaceId());
+    }
+}

Reply via email to