This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/main by this push:
new c865c8388 fix: Triple invocation with Json serialization (#2605)
c865c8388 is described below
commit c865c8388eadc6cca5cbf473ebc9c684786c9b47
Author: Scout Wang <[email protected]>
AuthorDate: Tue Mar 5 16:36:57 2024 +0800
fix: Triple invocation with Json serialization (#2605)
---
protocol/triple/client.go | 1 +
protocol/triple/triple_test.go | 16 +++++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/protocol/triple/client.go b/protocol/triple/client.go
index efbc8be6a..66a3e5331 100644
--- a/protocol/triple/client.go
+++ b/protocol/triple/client.go
@@ -139,6 +139,7 @@ func newClientManager(url *common.URL) (*clientManager,
error) {
case constant.ProtobufSerialization:
isIDL = true
case constant.JSONSerialization:
+ isIDL = true
cliOpts = append(cliOpts, tri.WithProtoJSON())
case constant.Hessian2Serialization:
cliOpts = append(cliOpts, tri.WithHessian2())
diff --git a/protocol/triple/triple_test.go b/protocol/triple/triple_test.go
index b2d43ea64..19c9f6d95 100644
--- a/protocol/triple/triple_test.go
+++ b/protocol/triple/triple_test.go
@@ -189,7 +189,7 @@ func TestMain(m *testing.M) {
}
func TestInvoke(t *testing.T) {
- tripleInvokerInit := func(location string, port string, interfaceName
string, group string, version string, methods []string, info
*client.ClientInfo) (protocol.Invoker, error) {
+ tripleInvokerInit := func(location string, port string, interfaceName
string, group string, version string, methods []string, serialization string,
info *client.ClientInfo) (protocol.Invoker, error) {
newURL := common.NewURLWithOptions(
common.WithInterface(interfaceName),
common.WithLocation(location),
@@ -199,6 +199,7 @@ func TestInvoke(t *testing.T) {
)
newURL.SetParam(constant.GroupKey, group)
newURL.SetParam(constant.VersionKey, version)
+ newURL.SetParam(constant.SerializationKey, serialization)
return NewTripleInvoker(newURL)
}
dubbo3InvokerInit := func(location string, port string, interfaceName
string, group string, version string, svc common.RPCService) (protocol.Invoker,
error) {
@@ -433,22 +434,27 @@ func TestInvoke(t *testing.T) {
}
t.Run("triple2triple", func(t *testing.T) {
- invoker, err := tripleInvokerInit(localAddr, triplePort,
customTripleInterfaceName, "", "",
greettriple.GreetService_ClientInfo.MethodNames,
&greettriple.GreetService_ClientInfo)
+ invoker, err := tripleInvokerInit(localAddr, triplePort,
customTripleInterfaceName, "", "",
greettriple.GreetService_ClientInfo.MethodNames, "",
&greettriple.GreetService_ClientInfo)
+ assert.Nil(t, err)
+ invokeTripleCodeFunc(t, invoker, "")
+ })
+ t.Run("triple2triple_JsonSerialization", func(t *testing.T) {
+ invoker, err := tripleInvokerInit(localAddr, triplePort,
customTripleInterfaceName, "", "",
greettriple.GreetService_ClientInfo.MethodNames, constant.JSONSerialization,
&greettriple.GreetService_ClientInfo)
assert.Nil(t, err)
invokeTripleCodeFunc(t, invoker, "")
})
t.Run("triple2triple_Group1Version1", func(t *testing.T) {
- invoker, err := tripleInvokerInit(localAddr, triplePort,
customTripleInterfaceName, group, version,
greettriple.GreetService_ClientInfo.MethodNames,
&greettriple.GreetService_ClientInfo)
+ invoker, err := tripleInvokerInit(localAddr, triplePort,
customTripleInterfaceName, group, version,
greettriple.GreetService_ClientInfo.MethodNames, "",
&greettriple.GreetService_ClientInfo)
assert.Nil(t, err)
invokeTripleCodeFunc(t, invoker, api.GroupVersionIdentifier)
})
t.Run("triple2dubbo3", func(t *testing.T) {
- invoker, err := tripleInvokerInit(localAddr, dubbo3Port,
customDubbo3InterfaceName, "", "",
greettriple.GreetService_ClientInfo.MethodNames,
&greettriple.GreetService_ClientInfo)
+ invoker, err := tripleInvokerInit(localAddr, dubbo3Port,
customDubbo3InterfaceName, "", "",
greettriple.GreetService_ClientInfo.MethodNames, "",
&greettriple.GreetService_ClientInfo)
assert.Nil(t, err)
invokeTripleCodeFunc(t, invoker, "")
})
t.Run("triple2dubbo3_Group1Version1", func(t *testing.T) {
- invoker, err := tripleInvokerInit(localAddr, dubbo3Port,
customDubbo3InterfaceName, group, version,
greettriple.GreetService_ClientInfo.MethodNames,
&greettriple.GreetService_ClientInfo)
+ invoker, err := tripleInvokerInit(localAddr, dubbo3Port,
customDubbo3InterfaceName, group, version,
greettriple.GreetService_ClientInfo.MethodNames, "",
&greettriple.GreetService_ClientInfo)
assert.Nil(t, err)
invokeTripleCodeFunc(t, invoker,
dubbo3_api.GroupVersionIdentifier)
})