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

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


The following commit(s) were added to refs/heads/1.6 by this push:
     new 707fde8  merge bug fixes to 1.6 (#206)
707fde8 is described below

commit 707fde85027982890ab8813fae8315d560b110b4
Author: 望哥 <gelny...@163.com>
AuthorDate: Tue Jun 23 14:28:14 2020 +0800

    merge bug fixes to 1.6 (#206)
    
    * add license checker (#175)
    
    * add release note for v1.5.0 (#178)
    
    Co-authored-by: Xin.Zh <dragonchar...@foxmail.com>
    
    * Imp: cache in reflection (#179)
    
    * benchmark result
    
    * use cache in findField
    
    * encode benchmark
    
    * call field() once
    
    * remove version
    
    * fix import sync
    
    * cache in registerPOJO
    
    * add json bench result
    
    * prune unneccessary rtype.Field(index)
    
    * cache comment
    
    * rename cache
    
    * switch to if
    
    * remove return value name
    
    * findFieldWithCache
    
    * remove if check when fieldStruct is nil
    
    Co-authored-by: 望哥 <gelny...@163.com>
    
    * update dependency
    
    * rename serialize arg name
    
    * Create .asf.yaml
    
    * 优化hessian解码string性能,提升54%
    
    * optimize code.
    
    * optimize code.
    
    * fix code review.
    
    * optimize codes.
    
    * optimize cods.
    
    * optimize code.
    
    * update license
    
    * go.sum
    
    * ci go version
    
    * testify -> 1.4.0
    
    * testcase
    
    * travis.yml
    
    * decode value before reflect find
    
    * setvalue
    
    * decode nilPtr to nilPtr
    
    * fix get attachment lost nil key
    
    * manually import package
    
    * add ToMapStringString unit test
    
    * rename test function name with issue
    
    * setmap
    
    * support for decode emoji.
    
    * refactor code
    
    * add unit test.
    
    * add unit tests.
    
    * refactor tests.
    
    * Update travis/main.sh (#200)
    
    - Remove duplicate key 'webhooks'
    - Key 'matrix' is an alias for `jobs`, using `jobs`
    - Specify the os and dist explicitly
    
    * Mod: modify
    
    * Code format (#199)
    
    * .gitignore
    
    * code clean
    
    * code clean
    
    * remove length check
    
    * Fix: comments
    
    * Fix: format package
    
    * Fix #181: float32 accuracy issue (#196)
    
    * Fix #181: float32 accuracy issue
    
    * Fix go fmt failure
    
    * Add the unit test case for Issue181
    
    * Add encFloat32 in double.go to encode float32 type
    
    - Call encFloat32 to encode float32 while encoding
    - Add unit test case to test float32 encoding
    
    * Improve encFloat32 of double.go
    
    * Fix git fmt failure
    
    * add release note for v1.6.0 (#202)
    
    * add release note for v1.5.1
    
    * add release note for v1.5.1
    
    * add notice
    
    * update notice
    
    * =fix release note for v1.6.0
    
    * Fix: eunm encode in request get error (#203)
    
    * fix bug: eunm encode in request get error
    
    * fix mod
    
    * add ut
    
    * remove go.mod 1.13 to fix the ci
    
    Co-authored-by: Joe Zou <joe...@apache.org>
    Co-authored-by: Xin.Zh <dragonchar...@foxmail.com>
    Co-authored-by: huiren <zhr...@gmail.com>
    Co-authored-by: Huang YunKun <hty...@gmail.com>
    Co-authored-by: zonghaishang <y...@apache.org>
    Co-authored-by: fangyincheng <fangyc...@gmail.com>
    Co-authored-by: champly <cham...@outlook.com>
    Co-authored-by: wilson chen <willson.che...@gmail.com>
    Co-authored-by: fangyincheng <fangyinch...@sina.com>
    Co-authored-by: gaoxinge <gao...@gmail.com>
    Co-authored-by: panty <pantiany...@gmail.com>
---
 request.go      |  3 ++-
 request_test.go | 44 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/request.go b/request.go
index 020c789..82c1ef5 100644
--- a/request.go
+++ b/request.go
@@ -97,7 +97,8 @@ func getArgType(v interface{}) string {
        case map[interface{}]interface{}:
                // return  "java.util.HashMap"
                return "java.util.Map"
-
+       case POJOEnum:
+               return v.(POJOEnum).JavaClassName()
        //  Serialized tags for complex types
        default:
                t := reflect.TypeOf(v)
diff --git a/request_test.go b/request_test.go
index b5886db..2b7f1f3 100644
--- a/request_test.go
+++ b/request_test.go
@@ -19,6 +19,7 @@ package hessian
 
 import (
        "reflect"
+       "strconv"
        "testing"
        "time"
 )
@@ -27,6 +28,45 @@ import (
        "github.com/stretchr/testify/assert"
 )
 
+type TestEnumGender JavaEnum
+
+const (
+       MAN JavaEnum = iota
+       WOMAN
+)
+
+var genderName = map[JavaEnum]string{
+       MAN:   "MAN",
+       WOMAN: "WOMAN",
+}
+
+var genderValue = map[string]JavaEnum{
+       "MAN":   MAN,
+       "WOMAN": WOMAN,
+}
+
+func (g TestEnumGender) JavaClassName() string {
+       return "com.ikurento.test.TestEnumGender"
+}
+
+func (g TestEnumGender) String() string {
+       s, ok := genderName[JavaEnum(g)]
+       if ok {
+               return s
+       }
+
+       return strconv.Itoa(int(g))
+}
+
+func (g TestEnumGender) EnumValue(s string) JavaEnum {
+       v, ok := genderValue[s]
+       if ok {
+               return v
+       }
+
+       return InvalidJavaEnum
+}
+
 func TestPackRequest(t *testing.T) {
        bytes, err := packRequest(Service{
                Path:      "test",
@@ -49,9 +89,9 @@ func TestPackRequest(t *testing.T) {
 
 func TestGetArgsTypeList(t *testing.T) {
        type Test struct{}
-       str, err := getArgsTypeList([]interface{}{nil, 1, []int{2}, true, 
[]bool{false}, "a", []string{"b"}, Test{}, &Test{}, []Test{}, 
map[string]Test{}})
+       str, err := getArgsTypeList([]interface{}{nil, 1, []int{2}, true, 
[]bool{false}, "a", []string{"b"}, Test{}, &Test{}, []Test{}, 
map[string]Test{}, TestEnumGender(MAN)})
        assert.NoError(t, err)
-       assert.Equal(t, 
"VJ[JZ[ZLjava/lang/String;[Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Object;Ljava/util/Map;",
 str)
+       assert.Equal(t, 
"VJ[JZ[ZLjava/lang/String;[Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Object;Ljava/util/Map;Lcom/ikurento/test/TestEnumGender;",
 str)
 }
 
 func TestDescRegex(t *testing.T) {

Reply via email to