Aias00 opened a new issue, #6855:
URL: https://github.com/apache/shenyu/issues/6855

   ## Description
   `SpringMvcContract.parseRequestTemplate` constructs `new RequestTemplate()` 
(field `path` defaults to `null`) and only calls `setPath` when 
`methodMapping.value().length > 0`. A method such as `@GetMapping String 
health()` (valid Spring MVC, maps to the class root) leaves `path == null`. 
`ShenyuClientInvocationHandler.buildMethodHandlerMap` then does 
`requestTemplate.setPath(shenyuClientFactoryBean.getPath() + 
requestTemplate.getPath())` — with a class-level `@ShenyuClient(path="/api")`, 
`"/api" + null` evaluates to `"/apinull"`. With no class path, 
`RequestTemplate.request()` line 82 does `this.url + this.path` → `url + null` 
→ `"http://hostnull"`. Java string concatenation appends the literal `"null"`.
   
   ## Location
   - 
`shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/common/RequestTemplate.java:82`
   - 
`shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/support/SpringMvcContract.java:80-94`
   - 
`shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/proxy/ShenyuClientInvocationHandler.java:110-112`
   
   ## Impact
   Any `@ShenyuClient` method whose `@RequestMapping`/`@GetMapping` has no 
`value` (root-mapped) issues requests to a corrupted URL ending in `null` (e.g. 
`http://gateway/apinull` or `http://gatewaynull`), silently 404'ing or hitting 
the wrong path. This is a common, valid Spring-MVC annotation pattern.
   
   ## Suggested fix
   Default `path` to `""` in `RequestTemplate` (or guard `request()`: `this.url 
+ (this.path == null ? "" : this.path)`); ensure `SpringMvcContract` sets 
`path` to `""` when no value is present.
   
   ## Related existing
   None — distinct from #6632 (GW-SYNC-2, AbstractNodeDataSyncService wrong key 
segment, unrelated module).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to