higress-group/higress

http2dubbo 入参支持Integer类型

开放

#1,062 创建于 2024年6月26日

 (5 条评论) (0 个反应) (0 位负责人)Go (1,219 个派生)github user discovery
area/dubbohelp wanted

仓库指标

星标
 (9,036 个星标)
PR 合并指标
 (平均合并 7天 9小时) (30 天内合并 18 个 PR)

描述

If you are reporting any crash or any potential security issue, do not open an issue in this repo. Please report the issue via ASRC(Alibaba Security Response Center) where the issue will be triaged appropriately.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Ⅰ. Issue Description

http2dubbo验证接口多参数、多类型,java dubbo 服务的接口参数声明为 string 和 integer 时,会报错 given param not match the type .

Ⅱ. Describe what happened

java dubbo 服务的接口参数分别string 和 string 不会报错,string 和 Long 不会报错, string 和 integer 是会报错 can not transcode the request because the given param not match the type

If there is an exception, please attach the exception trace: image

[Envoy (Epoch 0)] [2024-06-26 14:45:41.801][49][warning][filter] Failed to resolve headers, error is INVALID_ARGUMENT: can not transcode the request because the given param not match the type
{"authority":"localhost","bytes_received":"0","bytes_sent":"90","downstream_local_address":"172.23.0.7:80","downstream_remote_address":"172.23.0.1:59090","duration":"0","istio_policy_status":"-","method":"GET","path":"/dubbo/test?name=abcdddc&age=2","protocol":"HTTP/1.1","request_id":"381cf076-6c78-42d0-8159-d67c77fea2dc","requested_server_name":"-","response_code":"400","response_flags":"-","route_name":"-","start_time":"2024-06-26T14:45:41.801Z","trace_id":"-","upstream_cluster":"outbound|20880||providers:com.example.demo.dubbo.api.DemoService::.DEFAULT-GROUP.public.nacos","upstream_host":"-","upstream_local_address":"-","upstream_service_time":"-","upstream_transport_failure_reason":"-","user_agent":"curl/7.29.0","x_forwarded_for":"172.23.0.1"}

Ⅲ. Describe what you expected to happen

期望返回 {"result":"Hello abcdddc#2"}

Ⅳ. How to reproduce it (as minimally and precisely as possible)

  1. 申明dubbo接口
package com.example.demo.dubbo.api;

public interface DemoService {

    String sayName(String name, Long age);

    String sayHello(String name);
}
  1. 实现 dubbo 接口
package com.example.demo.dubbo.service;

import com.example.demo.dubbo.api.DemoService;

import org.apache.dubbo.config.annotation.DubboService;

@DubboService
public class DemoServiceImpl implements DemoService {

    @Override
    public String sayName(String name, Integer age ) {
        return "Hello " + name + "#" + age;
    }

    @Override
    public String sayHello(String name) {
        return "Hello " + name;
    }
}
  1. 部署 dubbo 服务到nacos, 并参考 http2dubbo,配好 http2dubbo 的路由和协议转换,其中CRD配置如下:
apiVersion: networking.higress.io/v1
kind: Http2Rpc
metadata:
  name: httproute-http2rpc-demo
  namespace: higress-system
spec:
  dubbo: 
    service: com.example.demo.dubbo.api.DemoService
    version: 
    group: 
    methods: 
    - serviceMethod: sayHello
      headersAttach: "*"
      httpMethods: 
      - "GET"
      httpPath: "/dubbo/hello"
      params:
      - paramKey: name
        paramSource: QUERY
        paramType: "java.lang.String"
    - serviceMethod: sayName
      headersAttach: "*"
      httpMethods: 
      - "GET"
      httpPath: "/dubbo/test"
      params:
      - paramKey: name
        paramSource: QUERY
        paramType: "java.lang.String"       
      - paramKey: age
        paramSource: QUERY
        paramType: "java.lang.Integer"    
 
  1. curl 命令验证
# 单个参数
curl "localhost/dubbo/hello?name=abcdddc"
#期待返回
{"result":"Hello abcdddc"}

# 多个参数,不同类型
curl "localhost/dubbo/test?name=abcdddc&age=2"
# 期待返回
{"result":"Hello abcdddc#2"}

Ⅴ. Anything else we need to know?

拉了 higress 主分支的源码,搜到如下信息: image image

Ⅵ. Environment:

  • Higress version: 1.4.0
  • OS : centos7
  • Others: java、dubbo3服务使用dubbo协议

贡献者指南