You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "tell1014 (via GitHub)" <gi...@apache.org> on 2023/04/20 03:46:58 UTC

[GitHub] [dubbo] tell1014 opened a new issue, #12142: dubbo 3.1.9升级dubbo 3.2.0,在使用REST中发现了几个问题

tell1014 opened a new issue, #12142:
URL: https://github.com/apache/dubbo/issues/12142

   <!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy -->
   
   - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 3.1.9 -> 3.2.0
   * dubbo-rpc-rest:3.1.9 -> 3.2.0
   * Operating System version: win11
   * Java version: java 8
   
   ### Steps to reproduce this issue
   
   接口定义如下:
   `
   @Path("users")
   @Consumes({ContentType.APPLICATION_JSON_UTF_8})
   @Produces({MediaType.APPLICATION_JSON})
   public interface UserService {
   
       @GET
       Response getUsers();
   
       @POST
       Response createUser(Object user);
   
       @GET
       @Path("{uid}")
       Response getUserByUid(@PathParam("uid") String uid);
   
       @DELETE
       @Path("{uid}")
       Response deleteUserByUid(@PathParam("uid") String uid);
   
   }
   `
   
   以上使用dubbo发布为REST风格的服务(参见上面接口定义),把dubbo版本从3.1.9升级到3.2.0出现了几个问题,问题如下:
   1、不能出现相同的URI而HTTP method不同,导致服务不能启动;
       比如:GET http://127.0.0.1:8080/users 与 POST http://127.0.0.1:8080/users
                  GET http://127.0.0.1:8080/users/1 与 DELETE http://127.0.0.1:8080/users/1
       3.2.0版本的启动报错内容在最底下。
       注:这个问题在dubbo 3.1.9版本中并不会出现
   
   2、在dubbo 3.2.0中一个URI无论用什么HTTP method请求都可以成功;
       在接口定义的方法中中使用@GET注解,使用GET还是其他HTTP方法都可以正常访问且HTTP响应状态为200
       注:这个问题在dubbo 3.1.9版本中使用非注解的HTTP方法请求会得到HTTP status为405(Method Not Allowed)
   
   3、同样是javax.ws.rs.core.Response返回类型,但3.1.9和3.2.0版本在HTTP body中的内容不相同;
   在下面的实现中:
   `
   public Response getUsers() {
           HashMap<String, Object> map = new HashMap<>();
           map.put("code", 10000);
           map.put("msg", "ok~~~");
           return Response.serverError().entity(map).build();
       }
   `
   使用3.1.9版本的HTTP body为
   `
   {
   "msg": "ok~~~",
   "code": 10000
   }
   `
   
   使用3.2.0版本的HTTP body为
   `
   {
   "allowedMethods": [ ],
   "closed": false,
   "cookies": { },
   -"entity": {
   "msg": "ok~~~",
   "code": 10000
   },
   "entityClass": "java.util.HashMap",
   "headers": { },
   "length": -1,
   "links": [ ],
   "metadata": { },
   "reasonPhrase": "Internal Server Error",
   "status": 500,
   "statusInfo": "INTERNAL_SERVER_ERROR",
   "stringHeaders": { }
   }
   `
       在dubbo-rpc-rest 3.1.9版本中依赖的是jboss-jaxrs-api_2.0_spec而在dubbo-rpc-rest 3.2.0中依赖的是jboss-jaxrs-api_2.1_spec,在3.1.9中直接返回entity而3.2.0返回Response,造成这种差异的原因不知道是dubbo方面的原因还是jaxrs-api的原因,又或者项目配置的问题呢?
   
   
   
   3.2.0版本启动报错:
   `
   Exception in thread "main" java.lang.IllegalArgumentException: dubbo rest metadata resolve double path error,and contain path variable  is:  PathMatcher{path='/users/{uid}', version='null', group='null', port=null, hasPathVariable=true, contextPath='null'}, rest method metadata is: RestMethodMetadata{method=MethodDefinition [name=getUserByUid, parameterTypes=[java.lang.String], returnType=javax.ws.rs.core.Response], request=RequestMetadata{method='GET', path='/users/{uid}', params={}, headers={}, consumes=[application/json; charset=UTF-8], produces=[application/json]}, urlIndex=null, bodyIndex=null, headerMapIndex=null, bodyType='null', indexToName=null, formParams=null, indexToEncoded=null, argInfos=[ArgInfo{index=0, annotationNameAttribute='uid', paramAnnotationType=interface javax.ws.rs.PathParam, paramType=class java.lang.String, paramName='arg0', urlSplitIndex=2, defaultValue={0}, formContentType=false}], reflectMethod=public abstract javax.ws.rs.core.Response com.mydomain.te
 st.service.UserService.getUserByUid(java.lang.String), codeStyle=class org.apache.dubbo.metadata.rest.jaxrs.JAXRSServiceRestMetadataResolver}
   	at org.apache.dubbo.metadata.rest.ServiceRestMetadata.doublePathCheck(ServiceRestMetadata.java:144)
   	at org.apache.dubbo.metadata.rest.ServiceRestMetadata.addPathToServiceMap(ServiceRestMetadata.java:131)
   	at org.apache.dubbo.metadata.rest.ServiceRestMetadata.addRestMethodMetadata(ServiceRestMetadata.java:114)
   	at org.apache.dubbo.metadata.rest.AbstractServiceRestMetadataResolver.processRestMethodMetadata(AbstractServiceRestMetadataResolver.java:292)
   	at org.apache.dubbo.metadata.rest.AbstractServiceRestMetadataResolver.processAllRestMethodMetadata(AbstractServiceRestMetadataResolver.java:156)
   	at org.apache.dubbo.metadata.rest.AbstractServiceRestMetadataResolver.resolve(AbstractServiceRestMetadataResolver.java:118)
   	at org.apache.dubbo.rpc.protocol.rest.annotation.metadata.MetadataResolver.resolveProviderServiceMetadata(MetadataResolver.java:63)
   	at org.apache.dubbo.rpc.protocol.rest.RestProtocol.export(RestProtocol.java:88)
   	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:73)
   	at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.export(ProtocolSecurityWrapper.java:80)
   	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:79)
   	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:61)
   	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.export(ProtocolSerializationWrapper.java:47)
   	at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.export(InvokerCountWrapper.java:42)
   	at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
   	at org.apache.dubbo.registry.integration.RegistryProtocol.lambda$doLocalExport$3(RegistryProtocol.java:305)
   	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
   	at org.apache.dubbo.registry.integration.RegistryProtocol.doLocalExport(RegistryProtocol.java:303)
   	at org.apache.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:249)
   	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:66)
   	at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.export(ProtocolSecurityWrapper.java:80)
   	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:79)
   	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:58)
   	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.export(ProtocolSerializationWrapper.java:47)
   	at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.export(InvokerCountWrapper.java:42)
   	at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
   	at org.apache.dubbo.config.ServiceConfig.doExportUrl(ServiceConfig.java:748)
   	at org.apache.dubbo.config.ServiceConfig.exportRemote(ServiceConfig.java:726)
   	at org.apache.dubbo.config.ServiceConfig.exportUrl(ServiceConfig.java:667)
   	at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:459)
   	at org.apache.dubbo.config.ServiceConfig.lambda$doExportUrls$5(ServiceConfig.java:438)
   	at org.apache.dubbo.metrics.event.MetricsEventBus.post(MetricsEventBus.java:95)
   	at org.apache.dubbo.metrics.event.MetricsEventBus.post(MetricsEventBus.java:62)
   	at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:427)
   	at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:398)
   	at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:250)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.exportServiceInternal(DefaultModuleDeployer.java:363)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.exportServices(DefaultModuleDeployer.java:335)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:161)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:142)
   	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:113)
   	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:102)
   	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:47)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
   	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)
   	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
   	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938)
   	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
   	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
   	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85)
   	at com.mydomain.test.app.Application.main(Application.java:10)
   `
   


-- 
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: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] dubbo 3.1.9升级dubbo 3.2.0,在使用REST中发现了几个问题 [dubbo]

Posted by "CrazyHZM (via GitHub)" <gi...@apache.org>.
CrazyHZM closed issue #12142: dubbo 3.1.9升级dubbo 3.2.0,在使用REST中发现了几个问题
URL: https://github.com/apache/dubbo/issues/12142


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] jojocodeX commented on issue #12142: dubbo 3.1.9升级dubbo 3.2.0,在使用REST中发现了几个问题

Posted by "jojocodeX (via GitHub)" <gi...@apache.org>.
jojocodeX commented on issue #12142:
URL: https://github.com/apache/dubbo/issues/12142#issuecomment-1537429310

   > * [ ]  I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   > 
   > ### Environment
   > * Dubbo version: 3.1.9 -> 3.2.0
   > * dubbo-rpc-rest:3.1.9 -> 3.2.0
   > * Operating System version: win11
   > * Java version: java 8
   > 
   > ### Steps to reproduce this issue
   > 接口定义如下: ` @path("users") @consumes({ContentType.APPLICATION_JSON_UTF_8}) @produces({MediaType.APPLICATION_JSON}) public interface UserService {
   > 
   > ```
   > @GET
   > Response getUsers();
   > 
   > @POST
   > Response createUser(Object user);
   > 
   > @GET
   > @Path("{uid}")
   > Response getUserByUid(@PathParam("uid") String uid);
   > 
   > @DELETE
   > @Path("{uid}")
   > Response deleteUserByUid(@PathParam("uid") String uid);
   > ```
   > 
   > } `
   > 
   > 以上使用dubbo发布为REST风格的服务(参见上面接口定义),把dubbo版本从3.1.9升级到3.2.0出现了几个问题,问题如下: 1、不能出现相同的URI而HTTP method不同,导致服务不能启动; 比如:GET http://127.0.0.1:8080/users 与 POST http://127.0.0.1:8080/users GET http://127.0.0.1:8080/users/1 与 DELETE http://127.0.0.1:8080/users/1 3.2.0版本的启动报错内容在最底下。 注:这个问题在dubbo 3.1.9版本中并不会出现
   > 
   > 2、在dubbo 3.2.0中一个URI无论用什么HTTP method请求都可以成功; 在接口定义的方法中中使用@get注解,使用GET还是其他HTTP方法都可以正常访问且HTTP响应状态为200 注:这个问题在dubbo 3.1.9版本中使用非注解的HTTP方法请求会得到HTTP status为405(Method Not Allowed)
   > 
   > 3、同样是javax.ws.rs.core.Response返回类型,但3.1.9和3.2.0版本在HTTP body中的内容不相同; 在下面的实现中: public Response getUsers() { HashMap<String, Object> map = new HashMap<>(); map.put("code", 10000); map.put("msg", "ok~~~"); return Response.serverError().entity(map).build(); }
   > 
   > 使用3.1.9版本的HTTP body为 { "msg": "ok~~~", "code": 10000 }
   > 
   > 使用3.2.0版本的HTTP body为 { "allowedMethods": [ ], "closed": false, "cookies": { }, -"entity": { "msg": "ok~~~", "code": 10000 }, "entityClass": "java.util.HashMap", "headers": { }, "length": -1, "links": [ ], "metadata": { }, "reasonPhrase": "Internal Server Error", "status": 500, "statusInfo": "INTERNAL_SERVER_ERROR", "stringHeaders": { } }
   > 
   > 在dubbo-rpc-rest 3.1.9版本中依赖的是jboss-jaxrs-api_2.0_spec而在dubbo-rpc-rest 3.2.0中依赖的是jboss-jaxrs-api_2.1_spec,在3.1.9中直接返回entity而3.2.0返回Response,造成这种差异的原因不知道是dubbo方面的原因还是jaxrs-api的原因,又或者项目配置的问题呢?
   > 
   > 3.2.0版本启动报错: `Exception in thread "main" java.lang.IllegalArgumentException: dubbo rest metadata resolve double path error,and contain path variable is: PathMatcher{path='/users/{uid}', version='null', group='null', port=null, hasPathVariable=true, contextPath='null'}, rest method metadata is: RestMethodMetadata{method=MethodDefinition [name=getUserByUid, parameterTypes=[java.lang.String], returnType=javax.ws.rs.core.Response], request=RequestMetadata{method='GET', path='/users/{uid}', params={}, headers={}, consumes=[application/json; charset=UTF-8], produces=[application/json]}, urlIndex=null, bodyIndex=null, headerMapIndex=null, bodyType='null', indexToName=null, formParams=null, indexToEncoded=null, argInfos=[ArgInfo{index=0, annotationNameAttribute='uid', paramAnnotationType=interface javax.ws.rs.PathParam, paramType=class java.lang.String, paramName='arg0', urlSplitIndex=2, defaultValue={0}, formContentType=false}], reflectMethod=public abstract javax.ws.rs.c
 ore.Response com.mydomain.test.service.UserService.getUserByUid(java.lang.String), codeStyle=class org.apache.dubbo.metadata.rest.jaxrs.JAXRSServiceRestMetadataResolver} at org.apache.dubbo.metadata.rest.ServiceRestMetadata.doublePathCheck(ServiceRestMetadata.java:144) at org.apache.dubbo.metadata.rest.ServiceRestMetadata.addPathToServiceMap(ServiceRestMetadata.java:131) at org.apache.dubbo.metadata.rest.ServiceRestMetadata.addRestMethodMetadata(ServiceRestMetadata.java:114) at org.apache.dubbo.metadata.rest.AbstractServiceRestMetadataResolver.processRestMethodMetadata(AbstractServiceRestMetadataResolver.java:292) at org.apache.dubbo.metadata.rest.AbstractServiceRestMetadataResolver.processAllRestMethodMetadata(AbstractServiceRestMetadataResolver.java:156) at org.apache.dubbo.metadata.rest.AbstractServiceRestMetadataResolver.resolve(AbstractServiceRestMetadataResolver.java:118) at org.apache.dubbo.rpc.protocol.rest.annotation.metadata.MetadataResolver.resolveProviderServiceMetadata(
 MetadataResolver.java:63) at org.apache.dubbo.rpc.protocol.rest.RestProtocol.export(RestProtocol.java:88) at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:73) at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.export(ProtocolSecurityWrapper.java:80) at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:79) at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:61) at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.export(ProtocolSerializationWrapper.java:47) at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.export(InvokerCountWrapper.java:42) at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) at org.apache.dubbo.registry.integration.RegistryProtocol.lambda$doLocalExport$3(RegistryProtocol.java:305) at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) at org.apache.dubbo.registry.integration.Regist
 ryProtocol.doLocalExport(RegistryProtocol.java:303) at org.apache.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:249) at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:66) at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.export(ProtocolSecurityWrapper.java:80) at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:79) at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:58) at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.export(ProtocolSerializationWrapper.java:47) at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.export(InvokerCountWrapper.java:42) at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) at org.apache.dubbo.config.ServiceConfig.doExportUrl(ServiceConfig.java:748) at org.apache.dubbo.config.ServiceConfig.exportRemote(ServiceConfig.java:726) at org.apache.dubbo.config.ServiceConfig.exportUr
 l(ServiceConfig.java:667) at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:459) at org.apache.dubbo.config.ServiceConfig.lambda$doExportUrls$5(ServiceConfig.java:438) at org.apache.dubbo.metrics.event.MetricsEventBus.post(MetricsEventBus.java:95) at org.apache.dubbo.metrics.event.MetricsEventBus.post(MetricsEventBus.java:62) at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:427) at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:398) at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:250) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.exportServiceInternal(DefaultModuleDeployer.java:363) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.exportServices(DefaultModuleDeployer.java:335) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:161) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:142) at or
 g.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:113) at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:102) at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:47) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractAppl
 icationContext.java:378) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85) at com.mydomain.test.app.Application.main(Application.java:10)`
   
   声明返回Respons这种模式,客户端是通过服务发现的机制,基于 consumer 的方式调用,还是直接端项目通过http?


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #12142: dubbo 3.1.9升级dubbo 3.2.0,在使用REST中发现了几个问题

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12142:
URL: https://github.com/apache/dubbo/issues/12142#issuecomment-1515958894

   @suncairong163 PTAL


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] tell1014 commented on issue #12142: dubbo 3.1.9升级dubbo 3.2.0,在使用REST中发现了几个问题

Posted by "tell1014 (via GitHub)" <gi...@apache.org>.
tell1014 commented on issue #12142:
URL: https://github.com/apache/dubbo/issues/12142#issuecomment-1537439719

   > > * [ ]   I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   > > 
   > > ### Environment
   > > 
   > > * Dubbo version: 3.1.9 -> 3.2.0
   > > * dubbo-rpc-rest:3.1.9 -> 3.2.0
   > > * Operating System version: win11
   > > * Java version: java 8
   > > 
   > > ### Steps to reproduce this issue
   > > 接口定义如下: ` @path("users") @consumes({ContentType.APPLICATION_JSON_UTF_8}) @produces({MediaType.APPLICATION_JSON}) public interface UserService {
   > > ```
   > > @GET
   > > Response getUsers();
   > > 
   > > @POST
   > > Response createUser(Object user);
   > > 
   > > @GET
   > > @Path("{uid}")
   > > Response getUserByUid(@PathParam("uid") String uid);
   > > 
   > > @DELETE
   > > @Path("{uid}")
   > > Response deleteUserByUid(@PathParam("uid") String uid);
   > > ```
   > > 
   > > 
   > >     
   > >       
   > >     
   > > 
   > >       
   > >     
   > > 
   > >     
   > >   
   > > } `
   > > 以上使用dubbo发布为REST风格的服务(参见上面接口定义),把dubbo版本从3.1.9升级到3.2.0出现了几个问题,问题如下: 1、不能出现相同的URI而HTTP method不同,导致服务不能启动; 比如:GET http://127.0.0.1:8080/users 与 POST http://127.0.0.1:8080/users GET http://127.0.0.1:8080/users/1 与 DELETE http://127.0.0.1:8080/users/1 3.2.0版本的启动报错内容在最底下。 注:这个问题在dubbo 3.1.9版本中并不会出现
   > > 2、在dubbo 3.2.0中一个URI无论用什么HTTP method请求都可以成功; 在接口定义的方法中中使用@get注解,使用GET还是其他HTTP方法都可以正常访问且HTTP响应状态为200 注:这个问题在dubbo 3.1.9版本中使用非注解的HTTP方法请求会得到HTTP status为405(Method Not Allowed)
   > > 3、同样是javax.ws.rs.core.Response返回类型,但3.1.9和3.2.0版本在HTTP body中的内容不相同; 在下面的实现中: public Response getUsers() { HashMap<String, Object> map = new HashMap<>(); map.put("code", 10000); map.put("msg", "ok~~~"); return Response.serverError().entity(map).build(); }
   > > 使用3.1.9版本的HTTP body为 { "msg": "ok~~~", "code": 10000 }
   > > 使用3.2.0版本的HTTP body为 { "allowedMethods": [ ], "closed": false, "cookies": { }, -"entity": { "msg": "ok~~~", "code": 10000 }, "entityClass": "java.util.HashMap", "headers": { }, "length": -1, "links": [ ], "metadata": { }, "reasonPhrase": "Internal Server Error", "status": 500, "statusInfo": "INTERNAL_SERVER_ERROR", "stringHeaders": { } }
   > > 在dubbo-rpc-rest 3.1.9版本中依赖的是jboss-jaxrs-api_2.0_spec而在dubbo-rpc-rest 3.2.0中依赖的是jboss-jaxrs-api_2.1_spec,在3.1.9中直接返回entity而3.2.0返回Response,造成这种差异的原因不知道是dubbo方面的原因还是jaxrs-api的原因,又或者项目配置的问题呢?
   > > 3.2.0版本启动报错: `Exception in thread "main" java.lang.IllegalArgumentException: dubbo rest metadata resolve double path error,and contain path variable is: PathMatcher{path='/users/{uid}', version='null', group='null', port=null, hasPathVariable=true, contextPath='null'}, rest method metadata is: RestMethodMetadata{method=MethodDefinition [name=getUserByUid, parameterTypes=[java.lang.String], returnType=javax.ws.rs.core.Response], request=RequestMetadata{method='GET', path='/users/{uid}', params={}, headers={}, consumes=[application/json; charset=UTF-8], produces=[application/json]}, urlIndex=null, bodyIndex=null, headerMapIndex=null, bodyType='null', indexToName=null, formParams=null, indexToEncoded=null, argInfos=[ArgInfo{index=0, annotationNameAttribute='uid', paramAnnotationType=interface javax.ws.rs.PathParam, paramType=class java.lang.String, paramName='arg0', urlSplitIndex=2, defaultValue={0}, formContentType=false}], reflectMethod=public abstract javax.ws.rs
 .core.Response com.mydomain.test.service.UserService.getUserByUid(java.lang.String), codeStyle=class org.apache.dubbo.metadata.rest.jaxrs.JAXRSServiceRestMetadataResolver} at org.apache.dubbo.metadata.rest.ServiceRestMetadata.doublePathCheck(ServiceRestMetadata.java:144) at org.apache.dubbo.metadata.rest.ServiceRestMetadata.addPathToServiceMap(ServiceRestMetadata.java:131) at org.apache.dubbo.metadata.rest.ServiceRestMetadata.addRestMethodMetadata(ServiceRestMetadata.java:114) at org.apache.dubbo.metadata.rest.AbstractServiceRestMetadataResolver.processRestMethodMetadata(AbstractServiceRestMetadataResolver.java:292) at org.apache.dubbo.metadata.rest.AbstractServiceRestMetadataResolver.processAllRestMethodMetadata(AbstractServiceRestMetadataResolver.java:156) at org.apache.dubbo.metadata.rest.AbstractServiceRestMetadataResolver.resolve(AbstractServiceRestMetadataResolver.java:118) at org.apache.dubbo.rpc.protocol.rest.annotation.metadata.MetadataResolver.resolveProviderServiceMetadat
 a(MetadataResolver.java:63) at org.apache.dubbo.rpc.protocol.rest.RestProtocol.export(RestProtocol.java:88) at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:73) at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.export(ProtocolSecurityWrapper.java:80) at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:79) at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:61) at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.export(ProtocolSerializationWrapper.java:47) at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.export(InvokerCountWrapper.java:42) at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) at org.apache.dubbo.registry.integration.RegistryProtocol.lambda$doLocalExport$3(RegistryProtocol.java:305) at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) at org.apache.dubbo.registry.integration.Regi
 stryProtocol.doLocalExport(RegistryProtocol.java:303) at org.apache.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:249) at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:66) at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.export(ProtocolSecurityWrapper.java:80) at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:79) at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:58) at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.export(ProtocolSerializationWrapper.java:47) at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.export(InvokerCountWrapper.java:42) at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) at org.apache.dubbo.config.ServiceConfig.doExportUrl(ServiceConfig.java:748) at org.apache.dubbo.config.ServiceConfig.exportRemote(ServiceConfig.java:726) at org.apache.dubbo.config.ServiceConfig.export
 Url(ServiceConfig.java:667) at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:459) at org.apache.dubbo.config.ServiceConfig.lambda$doExportUrls$5(ServiceConfig.java:438) at org.apache.dubbo.metrics.event.MetricsEventBus.post(MetricsEventBus.java:95) at org.apache.dubbo.metrics.event.MetricsEventBus.post(MetricsEventBus.java:62) at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:427) at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:398) at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:250) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.exportServiceInternal(DefaultModuleDeployer.java:363) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.exportServices(DefaultModuleDeployer.java:335) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:161) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:142) at 
 org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:113) at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:102) at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:47) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractAp
 plicationContext.java:378) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85) at com.mydomain.test.app.Application.main(Application.java:10)`
   > 
   > 声明返回Respons这种模式,客户端是通过服务发现的机制,基于 consumer 的方式调用,还是直接端项目通过http?
   
   直接通过前端项目HTTP的,为了发布RESTful API的。


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org