JedrekWang opened a new issue, #3698: URL: https://github.com/apache/servicecomb-java-chassis/issues/3698
### 问题背景: cse服务作为消费者走透明RPC(没有服务中心)的方式调度三方Spring服务,无法调度Spring后缀为/的接口 ### 问题分析: 通过代码分析, 对于Spring框架来说, @PostMapping(path = "/getDemoList/") 无法接收 /getDemoList的请求 当cse服务走透明RPC方式(参考:https://servicecomb.apache.org/references/java-chassis/zh_CN/build-consumer/3rd-party-service-invoke.html), 提供的RPC schema无论@RequestMapping有没有trailing slash,调到Spring侧都没有带trailing slash 代码走读发现,cse都会走**org.apache.servicecomb.common.rest.definition.path.URLPathBuilder#initPathWriterList** 方法将请求的path进行处理,去除了后缀/,导致这种场景无法调通, 建议兼容这种场景,至少可以提供一个开关可以不去除用户配置的path信息 ### 复现版本 Spring版本: spring-boot-starter-parent 2.5.7 cse版本: 2.8.2 ### 复现demo cse侧: ```java @RestSchema(schemaId = "ProviderController") @RequestMapping(path = "/hello-service/") public class App { public static void main(String[] args) { BeanUtils.init(); // 加载Spring bean定义文件,开始微服务启动流程 } @PostMapping("getList/{name}") public List<String> getList(@PathVariable String name) { DemoProviderIntf client = BeanUtils.getContext().getBean(DemoProviderIntf.class); DemoInfo demoInfo = new DemoInfo(); demoInfo.setName(name); return client.getDemoList(demoInfo); } ```java @RequestMapping(path = "/demo") public interface DemoProviderIntf { @RequestMapping(path = "/getDemoList/", method = RequestMethod.POST) List<String> getDemoList(@RequestBody DemoInfo req); } ``` ```java @Configuration("demo") public class ThirdSvc extends ThirdServiceWithInvokerRegister { public ThirdSvc() { super("demo"); addSchema("schema-1", DemoProviderIntf.class); } } ``` ```java public class DemoInfo { public String getName() { return name; } public void setName(String name) { this.name = name; } private String name; } ``` Spring侧 ``` @RequestMapping("/demo") @RestController @SpringBootApplication public class SpringCustomerApplication { public static void main(String[] args) { SpringApplication.run(SpringCustomerApplication.class, args); } @PostMapping(path = "/getDemoList") public List<String> getDemoList(@RequestBody DemoInfo req) { return Arrays.asList(req.getName(), "xxx", "yyy"); } } ``` -- 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]
