This is an automated email from the ASF dual-hosted git repository.

laurence pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new 30b5e18  hessian2 support setting type of Java method parameters 
(#1625)
30b5e18 is described below

commit 30b5e183c57d9d07c0b06326e2125236fbe1b62c
Author: binbin.zhang <[email protected]>
AuthorDate: Mon Dec 6 20:40:46 2021 +0800

    hessian2 support setting type of Java method parameters (#1625)
---
 protocol/dubbo/impl/hessian.go      |  4 +++
 protocol/dubbo/impl/hessian_test.go | 60 +++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/protocol/dubbo/impl/hessian.go b/protocol/dubbo/impl/hessian.go
index fc3e73a..eaf3d4a 100644
--- a/protocol/dubbo/impl/hessian.go
+++ b/protocol/dubbo/impl/hessian.go
@@ -490,6 +490,10 @@ func getArgType(v interface{}) string {
                }
                switch t.Kind() {
                case reflect.Struct:
+                       p, ok := v.(hessian.Param)
+                       if ok {
+                               return p.JavaParamName()
+                       }
                        v, ok := v.(hessian.POJO)
                        if ok {
                                return v.JavaClassName()
diff --git a/protocol/dubbo/impl/hessian_test.go 
b/protocol/dubbo/impl/hessian_test.go
new file mode 100644
index 0000000..0c82451
--- /dev/null
+++ b/protocol/dubbo/impl/hessian_test.go
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package impl
+
+import (
+       "testing"
+)
+
+import (
+       "github.com/stretchr/testify/assert"
+)
+
+const (
+       dubboParam = "org.apache.dubbo.param"
+       dubboPojo  = "org.apache.dubbo.pojo"
+)
+
+type Param struct {
+}
+
+func (p *Param) JavaClassName() string {
+       return dubboPojo
+}
+
+func (p *Param) JavaParamName() string {
+       return dubboParam
+}
+
+type Pojo struct {
+}
+
+func (p *Pojo) JavaClassName() string {
+       return dubboPojo
+}
+
+func TestGetArgType(t *testing.T) {
+
+       t.Run("pojo", func(t *testing.T) {
+               assert.Equal(t, dubboPojo, getArgType(&Pojo{}))
+       })
+
+       t.Run("param", func(t *testing.T) {
+               assert.Equal(t, dubboParam, getArgType(&Param{}))
+       })
+}

Reply via email to