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 049a9efa29 fix: initialize RequestTemplate path field and add test 
coverage for empty path requests (#6954)
049a9efa29 is described below

commit 049a9efa29662fae63ac4018be29a580cc1f31b7
Author: Limbo <[email protected]>
AuthorDate: Sat Sep 5 21:38:11 2026 +0800

    fix: initialize RequestTemplate path field and add test coverage for empty 
path requests (#6954)
    
    Co-authored-by: aias00 <[email protected]>
---
 .../shenyu/sdk/core/common/RequestTemplate.java     |  2 +-
 .../shenyu/sdk/core/common/RequestTemplateTest.java | 11 +++++++++++
 .../sdk/spring/support/SpringMvcContractTest.java   | 21 +++++++++++++++++++++
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git 
a/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/common/RequestTemplate.java
 
b/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/common/RequestTemplate.java
index d2d9df6c1e..7b88bbe31f 100644
--- 
a/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/common/RequestTemplate.java
+++ 
b/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/common/RequestTemplate.java
@@ -45,7 +45,7 @@ public final class RequestTemplate {
 
     private String contextId;
 
-    private String path;
+    private String path = "";
 
     private ShenyuRequest.HttpMethod httpMethod;
 
diff --git 
a/shenyu-sdk/shenyu-sdk-core/src/test/java/org/apache/shenyu/sdk/core/common/RequestTemplateTest.java
 
b/shenyu-sdk/shenyu-sdk-core/src/test/java/org/apache/shenyu/sdk/core/common/RequestTemplateTest.java
index a2ec002dcf..0deddeac4c 100644
--- 
a/shenyu-sdk/shenyu-sdk-core/src/test/java/org/apache/shenyu/sdk/core/common/RequestTemplateTest.java
+++ 
b/shenyu-sdk/shenyu-sdk-core/src/test/java/org/apache/shenyu/sdk/core/common/RequestTemplateTest.java
@@ -85,6 +85,17 @@ public class RequestTemplateTest {
         Assert.assertNotNull(shenyuRequest);
     }
 
+    @Test
+    public void testRequestWithoutPath() {
+        RequestTemplate template = new RequestTemplate();
+        template.setUrl("http://gateway";);
+        template.setHttpMethod(ShenyuRequest.HttpMethod.GET);
+
+        ShenyuRequest shenyuRequest = template.request();
+
+        Assert.assertEquals("http://gateway";, shenyuRequest.getUrl());
+    }
+
     public void assertNotNull(final RequestTemplate requestTemplate) {
         Assert.assertNotNull(requestTemplate);
         Assert.assertNotNull(requestTemplate.getReturnType());
diff --git 
a/shenyu-sdk/shenyu-sdk-spring/src/test/java/org/apache/shenyu/sdk/spring/support/SpringMvcContractTest.java
 
b/shenyu-sdk/shenyu-sdk-spring/src/test/java/org/apache/shenyu/sdk/spring/support/SpringMvcContractTest.java
index 705ebf5f69..5f7e7a2e9a 100644
--- 
a/shenyu-sdk/shenyu-sdk-spring/src/test/java/org/apache/shenyu/sdk/spring/support/SpringMvcContractTest.java
+++ 
b/shenyu-sdk/shenyu-sdk-spring/src/test/java/org/apache/shenyu/sdk/spring/support/SpringMvcContractTest.java
@@ -51,12 +51,15 @@ public class SpringMvcContractTest {
 
     private static final Method DEL;
 
+    private static final Method HEALTH;
+
     static {
         try {
             FIND_BY_ID = InvocationClient.class.getDeclaredMethod("findById", 
String.class);
             INSERT = InvocationClient.class.getDeclaredMethod("insert", 
MetaData.class);
             UPDATE = InvocationClient.class.getDeclaredMethod("update", 
MetaData.class);
             DEL = InvocationClient.class.getDeclaredMethod("del", 
String.class);
+            HEALTH = InvocationClient.class.getDeclaredMethod("health");
         } catch (NoSuchMethodException e) {
             throw new RuntimeException(e);
         }
@@ -95,6 +98,17 @@ public class SpringMvcContractTest {
         assertEquals(template.getHttpMethod(), 
ShenyuRequest.HttpMethod.DELETE);
     }
 
+    @Test
+    public void parseRootMappingRequestTemplateTest() {
+        SpringMvcContract contract = new SpringMvcContract();
+
+        RequestTemplate template = contract.parseRequestTemplate(HEALTH, bean);
+
+        assertSame(template.getMethod(), HEALTH);
+        assertEquals("", template.getPath());
+        assertEquals(ShenyuRequest.HttpMethod.GET, template.getHttpMethod());
+    }
+
     @ShenyuClient(value = "invocationClient", path = "/dev/null")
     public interface InvocationClient {
 
@@ -129,6 +143,13 @@ public class SpringMvcContractTest {
          */
         @DeleteMapping("/delete")
         int del(@RequestParam("id") String id);
+
+        /**
+         * health check mapping.
+         * @return status
+         */
+        @GetMapping
+        String health();
     }
 
 }

Reply via email to