From 89d84bedafaf69675bcc0ad9355144894dcda986 Mon Sep 17 00:00:00 2001 From: Changeden Date: Sat, 18 Sep 2021 15:42:59 +0800 Subject: [PATCH 01/14] =?UTF-8?q?go=20struct=20name=20=E5=8A=A0=E5=85=A5Pk?= =?UTF-8?q?gPath=E4=BF=A1=E6=81=AF=EF=BC=8C=E7=94=A8=E4=BA=8E=E5=8C=BA?= =?UTF-8?q?=E5=88=86=E5=90=8C=E5=90=8D=E7=9A=84struct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pojo.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pojo.go b/pojo.go index b27a3c6c..b30a1c6f 100644 --- a/pojo.go +++ b/pojo.go @@ -126,6 +126,7 @@ func RegisterPOJOMapping(javaClassName string, o interface{}) int { defer pojoRegistry.Unlock() if goName, ok := pojoRegistry.j2g[javaClassName]; ok { + // TODO print warning message about duplicate registration JavaClass return pojoRegistry.registry[goName].index } @@ -143,8 +144,7 @@ func RegisterPOJOMapping(javaClassName string, o interface{}) int { ) sttInfo.typ = obtainValueType(o) - - sttInfo.goName = sttInfo.typ.String() + sttInfo.goName = getGoName(o) sttInfo.javaName = javaClassName sttInfo.inst = o pojoRegistry.j2g[sttInfo.javaName] = sttInfo.goName @@ -225,7 +225,7 @@ func unRegisterPOJO(o POJO) int { pojoRegistry.Lock() defer pojoRegistry.Unlock() - goName := obtainValueType(o).String() + goName := getGoName(o) if structInfo, ok := pojoRegistry.registry[goName]; ok { delete(pojoRegistry.j2g, structInfo.javaName) @@ -240,6 +240,11 @@ func unRegisterPOJO(o POJO) int { return -1 } +func getGoName(o interface{}) string { + goType := obtainValueType(o) + return goType.PkgPath() + "/" + goType.String() +} + func obtainValueType(o interface{}) reflect.Type { v := reflect.ValueOf(o) switch v.Kind() { From b8119a50d741c7fe148bfb1ae69ce58d024b5e6f Mon Sep 17 00:00:00 2001 From: Changeden Date: Wed, 22 Sep 2021 15:21:46 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=A4=9A=E7=A7=8D?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 9 +++++++++ list.go | 3 ++- pojo.go | 18 ++++++++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3ee2f1ed..30220f9f 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,17 @@ module github.com/apache/dubbo-go-hessian2 +go 1.17 + require ( github.com/dubbogo/gost v1.9.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.4.0 ) +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/objx v0.1.0 // indirect + gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 // indirect + gopkg.in/yaml.v2 v2.2.2 // indirect +) diff --git a/list.go b/list.go index da0ca392..b93f22e6 100644 --- a/list.go +++ b/list.go @@ -160,7 +160,8 @@ func (e *Encoder) writeTypedList(v interface{}) error { } value = UnpackPtrValue(value) - totype := UnpackPtrType(value.Type().Elem()).String() + goType := UnpackPtrType(value.Type().Elem()) + totype := combineGoName(goType) typeName := getListTypeName(totype) if typeName == "" { return perrors.New("no this type name: " + totype) diff --git a/pojo.go b/pojo.go index b30a1c6f..7c14662d 100644 --- a/pojo.go +++ b/pojo.go @@ -20,6 +20,7 @@ package hessian import ( "fmt" "reflect" + "regexp" "strings" "sync" "unicode" @@ -241,8 +242,21 @@ func unRegisterPOJO(o POJO) int { } func getGoName(o interface{}) string { - goType := obtainValueType(o) - return goType.PkgPath() + "/" + goType.String() + goType := reflect.TypeOf(o) + if reflect.Ptr == goType.Kind() { + goType = goType.Elem() + } + return combineGoName(goType) +} + +func combineGoName(t reflect.Type) string { + pkgPath := t.PkgPath() + goName := t.String() + if pkgPath == "" || + regexp.MustCompile(`^(github\.com/apache/dubbo-go-hessian2|time)`).Match([]byte(pkgPath)) { + return goName + } + return pkgPath + "/" + goName } func obtainValueType(o interface{}) reflect.Type { From d12e050b9b33ad91e55fc4b34631ba8041f3d35c Mon Sep 17 00:00:00 2001 From: Changeden Date: Wed, 22 Sep 2021 15:23:35 +0800 Subject: [PATCH 03/14] =?UTF-8?q?go.mod=E5=9B=9E=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/go.mod b/go.mod index 30220f9f..fb0a269b 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,7 @@ module github.com/apache/dubbo-go-hessian2 -go 1.17 - require ( github.com/dubbogo/gost v1.9.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.4.0 ) - -require ( - github.com/davecgh/go-spew v1.1.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/objx v0.1.0 // indirect - gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 // indirect - gopkg.in/yaml.v2 v2.2.2 // indirect -) From 98f6ead73d721133de9594cdae2b8f25a0213314 Mon Sep 17 00:00:00 2001 From: Changeden Date: Wed, 22 Sep 2021 16:24:47 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pojo.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pojo.go b/pojo.go index 7c14662d..5ec83b07 100644 --- a/pojo.go +++ b/pojo.go @@ -102,6 +102,8 @@ var ( } pojoType = reflect.TypeOf((*POJO)(nil)).Elem() javaEnumType = reflect.TypeOf((*POJOEnum)(nil)).Elem() + + goPkgPathWhiteListRegexp = regexp.MustCompile(`^(github\.com/apache/dubbo-go-hessian2|time)`) ) // struct parsing @@ -243,7 +245,7 @@ func unRegisterPOJO(o POJO) int { func getGoName(o interface{}) string { goType := reflect.TypeOf(o) - if reflect.Ptr == goType.Kind() { + for reflect.Ptr == goType.Kind() { goType = goType.Elem() } return combineGoName(goType) @@ -252,8 +254,7 @@ func getGoName(o interface{}) string { func combineGoName(t reflect.Type) string { pkgPath := t.PkgPath() goName := t.String() - if pkgPath == "" || - regexp.MustCompile(`^(github\.com/apache/dubbo-go-hessian2|time)`).Match([]byte(pkgPath)) { + if pkgPath == "" || goPkgPathWhiteListRegexp.Match([]byte(pkgPath)) { return goName } return pkgPath + "/" + goName From 1a59e827be6e4c903335b9a8da7054036ce451c5 Mon Sep 17 00:00:00 2001 From: Changeden Date: Wed, 22 Sep 2021 18:06:18 +0800 Subject: [PATCH 05/14] Add Unit Tests --- dup_struct_name_demo/go.mod | 2 + dup_struct_name_demo/hessian.go | 26 +++++++++ dup_struct_name_test.go | 100 ++++++++++++++++++++++++++++++++ go.mod | 3 + 4 files changed, 131 insertions(+) create mode 100644 dup_struct_name_demo/go.mod create mode 100644 dup_struct_name_demo/hessian.go create mode 100644 dup_struct_name_test.go diff --git a/dup_struct_name_demo/go.mod b/dup_struct_name_demo/go.mod new file mode 100644 index 00000000..d4cf2310 --- /dev/null +++ b/dup_struct_name_demo/go.mod @@ -0,0 +1,2 @@ +module dup_struct_name + diff --git a/dup_struct_name_demo/hessian.go b/dup_struct_name_demo/hessian.go new file mode 100644 index 00000000..14bf74f4 --- /dev/null +++ b/dup_struct_name_demo/hessian.go @@ -0,0 +1,26 @@ +/* + * 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 hessian + +type CaseZ struct { + Name string +} + +func (CaseZ) JavaClassName() string { + return "com.test.caseZz" +} diff --git a/dup_struct_name_test.go b/dup_struct_name_test.go new file mode 100644 index 00000000..324a9f2b --- /dev/null +++ b/dup_struct_name_test.go @@ -0,0 +1,100 @@ +/* + * 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 hessian + +import ( + "bufio" + "bytes" + dup "dup_struct_name" + "github.com/stretchr/testify/assert" + "testing" +) + +type CaseZ struct { + Name string +} + +func (CaseZ) JavaClassName() string { + return "com.test.caseZ" +} + +func TestDupStructNameRequest(t *testing.T) { + RegisterPOJO(&dup.CaseZ{}) + RegisterPOJO(&CaseZ{}) + + packageType := PackageRequest + responseStatus := Zero + var body interface{} + body = []interface{}{"a"} + resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body) + assert.Nil(t, err) + + codecR := NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) + + h := &DubboHeader{} + err = codecR.ReadHeader(h) + assert.Nil(t, err) + assert.Equal(t, byte(2), h.SerialID) + assert.Equal(t, packageType, h.Type&(PackageRequest|PackageResponse|PackageHeartbeat)) + assert.Equal(t, int64(1), h.ID) + assert.Equal(t, responseStatus, h.ResponseStatus) + + c := make([]interface{}, 7) + err = codecR.ReadBody(c) + assert.Nil(t, err) + t.Log(c) + assert.True(t, len(body.([]interface{})) == len(c[5].([]interface{}))) +} + +func TestDupStructNameResponse(t *testing.T) { + RegisterPOJO(&dup.CaseZ{}) + RegisterPOJO(&CaseZ{}) + + packageType := PackageResponse + responseStatus := Response_OK + var body interface{} + body = &CaseZ{Name: "TestDupStructNameResponse"} + resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body) + assert.Nil(t, err) + + codecR := NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) + + h := &DubboHeader{} + err = codecR.ReadHeader(h) + assert.Nil(t, err) + + assert.Equal(t, byte(2), h.SerialID) + assert.Equal(t, packageType, h.Type&(PackageRequest|PackageResponse|PackageHeartbeat)) + assert.Equal(t, int64(1), h.ID) + assert.Equal(t, responseStatus, h.ResponseStatus) + + decodedResponse := &Response{} + decodedResponse.RspObj = &CaseZ{} + err = codecR.ReadBody(decodedResponse) + assert.Nil(t, err) + t.Log(decodedResponse) + + if h.ResponseStatus != Zero && h.ResponseStatus != Response_OK { + assert.Equal(t, "java exception:"+body.(string), decodedResponse.Exception.Error()) + return + } + + in, _ := EnsureInterface(UnpackPtrValue(EnsurePackValue(body)), nil) + out, _ := EnsureInterface(UnpackPtrValue(EnsurePackValue(decodedResponse.RspObj)), nil) + assert.Equal(t, in, out) +} diff --git a/go.mod b/go.mod index fb0a269b..4623c784 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,10 @@ module github.com/apache/dubbo-go-hessian2 require ( + dup_struct_name v0.0.0 github.com/dubbogo/gost v1.9.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.4.0 ) + +replace dup_struct_name => ./dup_struct_name_demo From 8f630f53d03cc9889d5e39751db797c757e62bf9 Mon Sep 17 00:00:00 2001 From: Changeden Date: Thu, 23 Sep 2021 09:43:52 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 3 - .../dup_struct_name_demo}/go.mod | 0 .../dup_struct_name_demo}/hessian.go | 2 +- .../dup_struct_name_test.go | 77 ++++++++++++++----- hessian_dup_struct_name_test/go.mod | 22 ++++++ hessian_dup_struct_name_test/go.sum | 16 ++++ 6 files changed, 95 insertions(+), 25 deletions(-) rename {dup_struct_name_demo => hessian_dup_struct_name_test/dup_struct_name_demo}/go.mod (100%) rename {dup_struct_name_demo => hessian_dup_struct_name_test/dup_struct_name_demo}/hessian.go (97%) rename dup_struct_name_test.go => hessian_dup_struct_name_test/dup_struct_name_test.go (51%) create mode 100644 hessian_dup_struct_name_test/go.mod create mode 100644 hessian_dup_struct_name_test/go.sum diff --git a/go.mod b/go.mod index 4623c784..fb0a269b 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,7 @@ module github.com/apache/dubbo-go-hessian2 require ( - dup_struct_name v0.0.0 github.com/dubbogo/gost v1.9.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.4.0 ) - -replace dup_struct_name => ./dup_struct_name_demo diff --git a/dup_struct_name_demo/go.mod b/hessian_dup_struct_name_test/dup_struct_name_demo/go.mod similarity index 100% rename from dup_struct_name_demo/go.mod rename to hessian_dup_struct_name_test/dup_struct_name_demo/go.mod diff --git a/dup_struct_name_demo/hessian.go b/hessian_dup_struct_name_test/dup_struct_name_demo/hessian.go similarity index 97% rename from dup_struct_name_demo/hessian.go rename to hessian_dup_struct_name_test/dup_struct_name_demo/hessian.go index 14bf74f4..47374466 100644 --- a/dup_struct_name_demo/hessian.go +++ b/hessian_dup_struct_name_test/dup_struct_name_demo/hessian.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package hessian +package hessian_test type CaseZ struct { Name string diff --git a/dup_struct_name_test.go b/hessian_dup_struct_name_test/dup_struct_name_test.go similarity index 51% rename from dup_struct_name_test.go rename to hessian_dup_struct_name_test/dup_struct_name_test.go index 324a9f2b..bd6cedc6 100644 --- a/dup_struct_name_test.go +++ b/hessian_dup_struct_name_test/dup_struct_name_test.go @@ -15,14 +15,20 @@ * limitations under the License. */ -package hessian +package hessian_test import ( "bufio" "bytes" dup "dup_struct_name" + "github.com/apache/dubbo-go-hessian2" "github.com/stretchr/testify/assert" "testing" + "time" +) + +const ( + EXPECTED_ERROR_MSG = "reflect.Set: value of type hessian_test.CaseZ is not assignable to type hessian_test.CaseZ" ) type CaseZ struct { @@ -33,24 +39,41 @@ func (CaseZ) JavaClassName() string { return "com.test.caseZ" } -func TestDupStructNameRequest(t *testing.T) { - RegisterPOJO(&dup.CaseZ{}) - RegisterPOJO(&CaseZ{}) +func doTestHessianEncodeHeader(t *testing.T, packageType hessian.PackageType, responseStatus byte, body interface{}) ([]byte, error) { + hessian.RegisterPOJO(&dup.CaseZ{}) + hessian.RegisterPOJO(&CaseZ{}) + codecW := hessian.NewHessianCodec(nil) + resp, err := codecW.Write(hessian.Service{ + Path: "test", + Interface: "ITest", + Version: "v1.0", + Method: "test", + Timeout: time.Second * 10, + }, hessian.DubboHeader{ + SerialID: 2, + Type: packageType, + ID: 1, + ResponseStatus: responseStatus, + }, body) + assert.Nil(t, err) + return resp, err +} - packageType := PackageRequest - responseStatus := Zero +func TestDupStructNameRequest(t *testing.T) { + packageType := hessian.PackageRequest + responseStatus := hessian.Zero var body interface{} body = []interface{}{"a"} resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body) assert.Nil(t, err) - codecR := NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) + codecR := hessian.NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) - h := &DubboHeader{} + h := &hessian.DubboHeader{} err = codecR.ReadHeader(h) assert.Nil(t, err) assert.Equal(t, byte(2), h.SerialID) - assert.Equal(t, packageType, h.Type&(PackageRequest|PackageResponse|PackageHeartbeat)) + assert.Equal(t, packageType, h.Type&(hessian.PackageRequest|hessian.PackageResponse|hessian.PackageHeartbeat)) assert.Equal(t, int64(1), h.ID) assert.Equal(t, responseStatus, h.ResponseStatus) @@ -62,39 +85,51 @@ func TestDupStructNameRequest(t *testing.T) { } func TestDupStructNameResponse(t *testing.T) { - RegisterPOJO(&dup.CaseZ{}) - RegisterPOJO(&CaseZ{}) - - packageType := PackageResponse - responseStatus := Response_OK + packageType := hessian.PackageResponse + responseStatus := hessian.Response_OK var body interface{} body = &CaseZ{Name: "TestDupStructNameResponse"} resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body) assert.Nil(t, err) - codecR := NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) + codecR := hessian.NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) - h := &DubboHeader{} + h := &hessian.DubboHeader{} err = codecR.ReadHeader(h) assert.Nil(t, err) assert.Equal(t, byte(2), h.SerialID) - assert.Equal(t, packageType, h.Type&(PackageRequest|PackageResponse|PackageHeartbeat)) + assert.Equal(t, packageType, h.Type&(hessian.PackageRequest|hessian.PackageResponse|hessian.PackageHeartbeat)) assert.Equal(t, int64(1), h.ID) assert.Equal(t, responseStatus, h.ResponseStatus) - decodedResponse := &Response{} + defer func() { + if err := recover(); err != nil { + if errStr, ok := err.(string); ok { + assert.Equal(t, EXPECTED_ERROR_MSG, errStr) + } + } + }() + + decodedResponse := &hessian.Response{} + decodedResponse.RspObj = &dup.CaseZ{} + err = codecR.ReadBody(decodedResponse) + assert.NotNil(t, err) + assert.Equal(t, EXPECTED_ERROR_MSG, err.Error()) + + decodedResponse = &hessian.Response{} decodedResponse.RspObj = &CaseZ{} err = codecR.ReadBody(decodedResponse) assert.Nil(t, err) + t.Log(decodedResponse) - if h.ResponseStatus != Zero && h.ResponseStatus != Response_OK { + if h.ResponseStatus != hessian.Zero && h.ResponseStatus != hessian.Response_OK { assert.Equal(t, "java exception:"+body.(string), decodedResponse.Exception.Error()) return } - in, _ := EnsureInterface(UnpackPtrValue(EnsurePackValue(body)), nil) - out, _ := EnsureInterface(UnpackPtrValue(EnsurePackValue(decodedResponse.RspObj)), nil) + in, _ := hessian.EnsureInterface(hessian.UnpackPtrValue(hessian.EnsurePackValue(body)), nil) + out, _ := hessian.EnsureInterface(hessian.UnpackPtrValue(hessian.EnsurePackValue(decodedResponse.RspObj)), nil) assert.Equal(t, in, out) } diff --git a/hessian_dup_struct_name_test/go.mod b/hessian_dup_struct_name_test/go.mod new file mode 100644 index 00000000..79ef38ec --- /dev/null +++ b/hessian_dup_struct_name_test/go.mod @@ -0,0 +1,22 @@ +module hessian_test + +go 1.17 + +require ( + dup_struct_name v0.0.0 + github.com/apache/dubbo-go-hessian2 v0.0.0 + github.com/stretchr/testify v1.4.0 +) + +require ( + github.com/davecgh/go-spew v1.1.0 + github.com/dubbogo/gost v1.9.0 + github.com/pkg/errors v0.9.1 + github.com/pmezard/go-difflib v1.0.0 + gopkg.in/yaml.v2 v2.2.2 +) + +replace ( + dup_struct_name => ./dup_struct_name_demo + github.com/apache/dubbo-go-hessian2 => ../ +) diff --git a/hessian_dup_struct_name_test/go.sum b/hessian_dup_struct_name_test/go.sum new file mode 100644 index 00000000..1c6b1fd4 --- /dev/null +++ b/hessian_dup_struct_name_test/go.sum @@ -0,0 +1,16 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dubbogo/gost v1.9.0 h1:UT+dWwvLyJiDotxJERO75jB3Yxgsdy10KztR5ycxRAk= +github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From b701ba18522852664a1db7c2a2843a74eb5bf7d8 Mon Sep 17 00:00:00 2001 From: Changeden Date: Thu, 23 Sep 2021 10:05:19 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BC=82=E6=9E=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dup_struct_name_test.go | 62 +++++++++++++++---- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/hessian_dup_struct_name_test/dup_struct_name_test.go b/hessian_dup_struct_name_test/dup_struct_name_test.go index bd6cedc6..521f5622 100644 --- a/hessian_dup_struct_name_test/dup_struct_name_test.go +++ b/hessian_dup_struct_name_test/dup_struct_name_test.go @@ -85,24 +85,33 @@ func TestDupStructNameRequest(t *testing.T) { } func TestDupStructNameResponse(t *testing.T) { - packageType := hessian.PackageResponse - responseStatus := hessian.Response_OK + defer func() { + if err := recover(); err != nil { + if errStr, ok := err.(string); ok { + assert.Equal(t, EXPECTED_ERROR_MSG, errStr) + } + } + }() + var body interface{} body = &CaseZ{Name: "TestDupStructNameResponse"} - resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body) - assert.Nil(t, err) + err, codecR, h := doTestHeader(t, body) - codecR := hessian.NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) + decodedResponse := &hessian.Response{} + decodedResponse.RspObj = &dup.CaseZ{} + err = codecR.ReadBody(decodedResponse) + assert.NotNil(t, err) + assert.Equal(t, EXPECTED_ERROR_MSG, err.Error()) - h := &hessian.DubboHeader{} - err = codecR.ReadHeader(h) + decodedResponse = &hessian.Response{} + decodedResponse.RspObj = &CaseZ{} + err = codecR.ReadBody(decodedResponse) assert.Nil(t, err) - assert.Equal(t, byte(2), h.SerialID) - assert.Equal(t, packageType, h.Type&(hessian.PackageRequest|hessian.PackageResponse|hessian.PackageHeartbeat)) - assert.Equal(t, int64(1), h.ID) - assert.Equal(t, responseStatus, h.ResponseStatus) + checkResponseBody(t, decodedResponse, h, body) +} +func TestDupStructNameResponse2(t *testing.T) { defer func() { if err := recover(); err != nil { if errStr, ok := err.(string); ok { @@ -111,17 +120,44 @@ func TestDupStructNameResponse(t *testing.T) { } }() + var body interface{} + body = &dup.CaseZ{Name: "TestDupStructNameResponse"} + err, codecR, h := doTestHeader(t, body) + decodedResponse := &hessian.Response{} - decodedResponse.RspObj = &dup.CaseZ{} + decodedResponse.RspObj = &CaseZ{} err = codecR.ReadBody(decodedResponse) assert.NotNil(t, err) assert.Equal(t, EXPECTED_ERROR_MSG, err.Error()) decodedResponse = &hessian.Response{} - decodedResponse.RspObj = &CaseZ{} + decodedResponse.RspObj = &dup.CaseZ{} err = codecR.ReadBody(decodedResponse) assert.Nil(t, err) + checkResponseBody(t, decodedResponse, h, body) +} + +func doTestHeader(t *testing.T, body interface{}) (error, *hessian.HessianCodec, *hessian.DubboHeader) { + packageType := hessian.PackageResponse + responseStatus := hessian.Response_OK + resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body) + assert.Nil(t, err) + + codecR := hessian.NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) + + h := &hessian.DubboHeader{} + err = codecR.ReadHeader(h) + assert.Nil(t, err) + + assert.Equal(t, byte(2), h.SerialID) + assert.Equal(t, packageType, h.Type&(hessian.PackageRequest|hessian.PackageResponse|hessian.PackageHeartbeat)) + assert.Equal(t, int64(1), h.ID) + assert.Equal(t, responseStatus, h.ResponseStatus) + return err, codecR, h +} + +func checkResponseBody(t *testing.T, decodedResponse *hessian.Response, h *hessian.DubboHeader, body interface{}) { t.Log(decodedResponse) if h.ResponseStatus != hessian.Zero && h.ResponseStatus != hessian.Response_OK { From 1923caa9175833599c7c27bbbbf7f295c555b897 Mon Sep 17 00:00:00 2001 From: Changeden Date: Thu, 23 Sep 2021 11:17:27 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hessian_dup_struct_name_test/dup_struct_name_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hessian_dup_struct_name_test/dup_struct_name_test.go b/hessian_dup_struct_name_test/dup_struct_name_test.go index 521f5622..452b751d 100644 --- a/hessian_dup_struct_name_test/dup_struct_name_test.go +++ b/hessian_dup_struct_name_test/dup_struct_name_test.go @@ -20,11 +20,17 @@ package hessian_test import ( "bufio" "bytes" + "testing" + "time" +) + +import ( dup "dup_struct_name" +) + +import ( "github.com/apache/dubbo-go-hessian2" "github.com/stretchr/testify/assert" - "testing" - "time" ) const ( From 6e7538031b7b7b3b19482db1d3ce26e862bbabc5 Mon Sep 17 00:00:00 2001 From: Changeden Date: Thu, 23 Sep 2021 16:18:32 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ct_name_test.go => dup_struct_name_test.go | 72 ++++++++----------- go.mod | 5 ++ go.sum | 2 + .../dup_struct_name_demo/go.mod | 2 - .../dup_struct_name_demo/hessian.go | 26 ------- hessian_dup_struct_name_test/go.mod | 22 ------ hessian_dup_struct_name_test/go.sum | 16 ----- 7 files changed, 35 insertions(+), 110 deletions(-) rename hessian_dup_struct_name_test/dup_struct_name_test.go => dup_struct_name_test.go (61%) delete mode 100644 hessian_dup_struct_name_test/dup_struct_name_demo/go.mod delete mode 100644 hessian_dup_struct_name_test/dup_struct_name_demo/hessian.go delete mode 100644 hessian_dup_struct_name_test/go.mod delete mode 100644 hessian_dup_struct_name_test/go.sum diff --git a/hessian_dup_struct_name_test/dup_struct_name_test.go b/dup_struct_name_test.go similarity index 61% rename from hessian_dup_struct_name_test/dup_struct_name_test.go rename to dup_struct_name_test.go index 452b751d..7d563b89 100644 --- a/hessian_dup_struct_name_test/dup_struct_name_test.go +++ b/dup_struct_name_test.go @@ -15,26 +15,24 @@ * limitations under the License. */ -package hessian_test +package hessian import ( "bufio" "bytes" "testing" - "time" ) import ( - dup "dup_struct_name" + dup "dubbo-go-hessian2-dup-struct-name-test" ) import ( - "github.com/apache/dubbo-go-hessian2" "github.com/stretchr/testify/assert" ) const ( - EXPECTED_ERROR_MSG = "reflect.Set: value of type hessian_test.CaseZ is not assignable to type hessian_test.CaseZ" + EXPECTED_ERROR_MSG = "reflect.Set: value of type hessian.CaseZ is not assignable to type hessian.CaseZ" ) type CaseZ struct { @@ -45,41 +43,24 @@ func (CaseZ) JavaClassName() string { return "com.test.caseZ" } -func doTestHessianEncodeHeader(t *testing.T, packageType hessian.PackageType, responseStatus byte, body interface{}) ([]byte, error) { - hessian.RegisterPOJO(&dup.CaseZ{}) - hessian.RegisterPOJO(&CaseZ{}) - codecW := hessian.NewHessianCodec(nil) - resp, err := codecW.Write(hessian.Service{ - Path: "test", - Interface: "ITest", - Version: "v1.0", - Method: "test", - Timeout: time.Second * 10, - }, hessian.DubboHeader{ - SerialID: 2, - Type: packageType, - ID: 1, - ResponseStatus: responseStatus, - }, body) - assert.Nil(t, err) - return resp, err -} - func TestDupStructNameRequest(t *testing.T) { - packageType := hessian.PackageRequest - responseStatus := hessian.Zero + RegisterPOJO(&dup.CaseZ{}) + RegisterPOJO(&CaseZ{}) + + packageType := PackageRequest + responseStatus := Zero var body interface{} body = []interface{}{"a"} resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body) assert.Nil(t, err) - codecR := hessian.NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) + codecR := NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) - h := &hessian.DubboHeader{} + h := &DubboHeader{} err = codecR.ReadHeader(h) assert.Nil(t, err) assert.Equal(t, byte(2), h.SerialID) - assert.Equal(t, packageType, h.Type&(hessian.PackageRequest|hessian.PackageResponse|hessian.PackageHeartbeat)) + assert.Equal(t, packageType, h.Type&(PackageRequest|PackageResponse|PackageHeartbeat)) assert.Equal(t, int64(1), h.ID) assert.Equal(t, responseStatus, h.ResponseStatus) @@ -103,13 +84,13 @@ func TestDupStructNameResponse(t *testing.T) { body = &CaseZ{Name: "TestDupStructNameResponse"} err, codecR, h := doTestHeader(t, body) - decodedResponse := &hessian.Response{} + decodedResponse := &Response{} decodedResponse.RspObj = &dup.CaseZ{} err = codecR.ReadBody(decodedResponse) assert.NotNil(t, err) assert.Equal(t, EXPECTED_ERROR_MSG, err.Error()) - decodedResponse = &hessian.Response{} + decodedResponse = &Response{} decodedResponse.RspObj = &CaseZ{} err = codecR.ReadBody(decodedResponse) assert.Nil(t, err) @@ -130,13 +111,13 @@ func TestDupStructNameResponse2(t *testing.T) { body = &dup.CaseZ{Name: "TestDupStructNameResponse"} err, codecR, h := doTestHeader(t, body) - decodedResponse := &hessian.Response{} + decodedResponse := &Response{} decodedResponse.RspObj = &CaseZ{} err = codecR.ReadBody(decodedResponse) assert.NotNil(t, err) assert.Equal(t, EXPECTED_ERROR_MSG, err.Error()) - decodedResponse = &hessian.Response{} + decodedResponse = &Response{} decodedResponse.RspObj = &dup.CaseZ{} err = codecR.ReadBody(decodedResponse) assert.Nil(t, err) @@ -144,34 +125,37 @@ func TestDupStructNameResponse2(t *testing.T) { checkResponseBody(t, decodedResponse, h, body) } -func doTestHeader(t *testing.T, body interface{}) (error, *hessian.HessianCodec, *hessian.DubboHeader) { - packageType := hessian.PackageResponse - responseStatus := hessian.Response_OK +func doTestHeader(t *testing.T, body interface{}) (error, *HessianCodec, *DubboHeader) { + RegisterPOJO(&dup.CaseZ{}) + RegisterPOJO(&CaseZ{}) + + packageType := PackageResponse + responseStatus := Response_OK resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body) assert.Nil(t, err) - codecR := hessian.NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) + codecR := NewHessianCodec(bufio.NewReader(bytes.NewReader(resp))) - h := &hessian.DubboHeader{} + h := &DubboHeader{} err = codecR.ReadHeader(h) assert.Nil(t, err) assert.Equal(t, byte(2), h.SerialID) - assert.Equal(t, packageType, h.Type&(hessian.PackageRequest|hessian.PackageResponse|hessian.PackageHeartbeat)) + assert.Equal(t, packageType, h.Type&(PackageRequest|PackageResponse|PackageHeartbeat)) assert.Equal(t, int64(1), h.ID) assert.Equal(t, responseStatus, h.ResponseStatus) return err, codecR, h } -func checkResponseBody(t *testing.T, decodedResponse *hessian.Response, h *hessian.DubboHeader, body interface{}) { +func checkResponseBody(t *testing.T, decodedResponse *Response, h *DubboHeader, body interface{}) { t.Log(decodedResponse) - if h.ResponseStatus != hessian.Zero && h.ResponseStatus != hessian.Response_OK { + if h.ResponseStatus != Zero && h.ResponseStatus != Response_OK { assert.Equal(t, "java exception:"+body.(string), decodedResponse.Exception.Error()) return } - in, _ := hessian.EnsureInterface(hessian.UnpackPtrValue(hessian.EnsurePackValue(body)), nil) - out, _ := hessian.EnsureInterface(hessian.UnpackPtrValue(hessian.EnsurePackValue(decodedResponse.RspObj)), nil) + in, _ := EnsureInterface(UnpackPtrValue(EnsurePackValue(body)), nil) + out, _ := EnsureInterface(UnpackPtrValue(EnsurePackValue(decodedResponse.RspObj)), nil) assert.Equal(t, in, out) } diff --git a/go.mod b/go.mod index fb0a269b..1753ae2d 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,12 @@ module github.com/apache/dubbo-go-hessian2 +go 1.17 + require ( + dubbo-go-hessian2-dup-struct-name-test v0.0.2 github.com/dubbogo/gost v1.9.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.4.0 ) + +replace dubbo-go-hessian2-dup-struct-name-test v0.0.2 => github.com/ChangedenCZD/dubbo-go-hessian2-dup-struct-name-test v0.0.2 diff --git a/go.sum b/go.sum index f799fe33..638250de 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/ChangedenCZD/dubbo-go-hessian2-dup-struct-name-test v0.0.2 h1:r/eEBK6t2iZ/YDqMKYIbm/BLwjOhF424LWSj1Bs6aSE= +github.com/ChangedenCZD/dubbo-go-hessian2-dup-struct-name-test v0.0.2/go.mod h1:fHkCJ3VeG0Sl5TpciR5/2xt8jUlrQJaHg5uNcRxxR9M= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dubbogo/gost v1.9.0 h1:UT+dWwvLyJiDotxJERO75jB3Yxgsdy10KztR5ycxRAk= diff --git a/hessian_dup_struct_name_test/dup_struct_name_demo/go.mod b/hessian_dup_struct_name_test/dup_struct_name_demo/go.mod deleted file mode 100644 index d4cf2310..00000000 --- a/hessian_dup_struct_name_test/dup_struct_name_demo/go.mod +++ /dev/null @@ -1,2 +0,0 @@ -module dup_struct_name - diff --git a/hessian_dup_struct_name_test/dup_struct_name_demo/hessian.go b/hessian_dup_struct_name_test/dup_struct_name_demo/hessian.go deleted file mode 100644 index 47374466..00000000 --- a/hessian_dup_struct_name_test/dup_struct_name_demo/hessian.go +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 hessian_test - -type CaseZ struct { - Name string -} - -func (CaseZ) JavaClassName() string { - return "com.test.caseZz" -} diff --git a/hessian_dup_struct_name_test/go.mod b/hessian_dup_struct_name_test/go.mod deleted file mode 100644 index 79ef38ec..00000000 --- a/hessian_dup_struct_name_test/go.mod +++ /dev/null @@ -1,22 +0,0 @@ -module hessian_test - -go 1.17 - -require ( - dup_struct_name v0.0.0 - github.com/apache/dubbo-go-hessian2 v0.0.0 - github.com/stretchr/testify v1.4.0 -) - -require ( - github.com/davecgh/go-spew v1.1.0 - github.com/dubbogo/gost v1.9.0 - github.com/pkg/errors v0.9.1 - github.com/pmezard/go-difflib v1.0.0 - gopkg.in/yaml.v2 v2.2.2 -) - -replace ( - dup_struct_name => ./dup_struct_name_demo - github.com/apache/dubbo-go-hessian2 => ../ -) diff --git a/hessian_dup_struct_name_test/go.sum b/hessian_dup_struct_name_test/go.sum deleted file mode 100644 index 1c6b1fd4..00000000 --- a/hessian_dup_struct_name_test/go.sum +++ /dev/null @@ -1,16 +0,0 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dubbogo/gost v1.9.0 h1:UT+dWwvLyJiDotxJERO75jB3Yxgsdy10KztR5ycxRAk= -github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 3bc5076dd6505d6e99b082264ac96a109ca3b434 Mon Sep 17 00:00:00 2001 From: Changeden Date: Thu, 23 Sep 2021 16:22:11 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dup_struct_name_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dup_struct_name_test.go b/dup_struct_name_test.go index 7d563b89..f869257a 100644 --- a/dup_struct_name_test.go +++ b/dup_struct_name_test.go @@ -32,7 +32,7 @@ import ( ) const ( - EXPECTED_ERROR_MSG = "reflect.Set: value of type hessian.CaseZ is not assignable to type hessian.CaseZ" + ExpectedErrorMsg = "reflect.Set: value of type hessian.CaseZ is not assignable to type hessian.CaseZ" ) type CaseZ struct { @@ -75,7 +75,7 @@ func TestDupStructNameResponse(t *testing.T) { defer func() { if err := recover(); err != nil { if errStr, ok := err.(string); ok { - assert.Equal(t, EXPECTED_ERROR_MSG, errStr) + assert.Equal(t, ExpectedErrorMsg, errStr) } } }() @@ -88,7 +88,7 @@ func TestDupStructNameResponse(t *testing.T) { decodedResponse.RspObj = &dup.CaseZ{} err = codecR.ReadBody(decodedResponse) assert.NotNil(t, err) - assert.Equal(t, EXPECTED_ERROR_MSG, err.Error()) + assert.Equal(t, ExpectedErrorMsg, err.Error()) decodedResponse = &Response{} decodedResponse.RspObj = &CaseZ{} @@ -102,7 +102,7 @@ func TestDupStructNameResponse2(t *testing.T) { defer func() { if err := recover(); err != nil { if errStr, ok := err.(string); ok { - assert.Equal(t, EXPECTED_ERROR_MSG, errStr) + assert.Equal(t, ExpectedErrorMsg, errStr) } } }() @@ -110,12 +110,13 @@ func TestDupStructNameResponse2(t *testing.T) { var body interface{} body = &dup.CaseZ{Name: "TestDupStructNameResponse"} err, codecR, h := doTestHeader(t, body) + assert.Nil(t, err) decodedResponse := &Response{} decodedResponse.RspObj = &CaseZ{} err = codecR.ReadBody(decodedResponse) assert.NotNil(t, err) - assert.Equal(t, EXPECTED_ERROR_MSG, err.Error()) + assert.Equal(t, ExpectedErrorMsg, err.Error()) decodedResponse = &Response{} decodedResponse.RspObj = &dup.CaseZ{} From 0ded31873ba23daa1cbedd70756942a1b63e4d04 Mon Sep 17 00:00:00 2001 From: Changeden Date: Thu, 23 Sep 2021 16:25:04 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dup_struct_name_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/dup_struct_name_test.go b/dup_struct_name_test.go index f869257a..eb5ac873 100644 --- a/dup_struct_name_test.go +++ b/dup_struct_name_test.go @@ -83,6 +83,7 @@ func TestDupStructNameResponse(t *testing.T) { var body interface{} body = &CaseZ{Name: "TestDupStructNameResponse"} err, codecR, h := doTestHeader(t, body) + assert.Nil(t, err) decodedResponse := &Response{} decodedResponse.RspObj = &dup.CaseZ{} From 1ff13319288fe0bbd3fb7d2468f1e538a5e9b069 Mon Sep 17 00:00:00 2001 From: Changeden Date: Thu, 23 Sep 2021 18:58:50 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E7=A7=BB=E9=99=A4go=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.mod b/go.mod index 1753ae2d..6dcbc748 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,5 @@ module github.com/apache/dubbo-go-hessian2 -go 1.17 - require ( dubbo-go-hessian2-dup-struct-name-test v0.0.2 github.com/dubbogo/gost v1.9.0 From e03a8014deeed981417a5d1affb13ac2047d947b Mon Sep 17 00:00:00 2001 From: Changeden Date: Fri, 24 Sep 2021 22:36:44 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 6dcbc748..8cd9b09a 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/apache/dubbo-go-hessian2 require ( - dubbo-go-hessian2-dup-struct-name-test v0.0.2 + dubbo-go-hessian2-dup-struct-name-test v0.0.3 github.com/dubbogo/gost v1.9.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.4.0 ) -replace dubbo-go-hessian2-dup-struct-name-test v0.0.2 => github.com/ChangedenCZD/dubbo-go-hessian2-dup-struct-name-test v0.0.2 +replace dubbo-go-hessian2-dup-struct-name-test => github.com/changedenczd/dubbo-go-hessian2-dup-struct-name-test v0.0.3 From 89597335d9a2d3088a3361b52c6171b886e6fecf Mon Sep 17 00:00:00 2001 From: Changeden Date: Sat, 25 Sep 2021 14:29:20 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E7=A7=BB=E9=99=A4go=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.sum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.sum b/go.sum index 638250de..13e54d4c 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/ChangedenCZD/dubbo-go-hessian2-dup-struct-name-test v0.0.2 h1:r/eEBK6t2iZ/YDqMKYIbm/BLwjOhF424LWSj1Bs6aSE= -github.com/ChangedenCZD/dubbo-go-hessian2-dup-struct-name-test v0.0.2/go.mod h1:fHkCJ3VeG0Sl5TpciR5/2xt8jUlrQJaHg5uNcRxxR9M= +github.com/changedenczd/dubbo-go-hessian2-dup-struct-name-test v0.0.3 h1:31bvQXq/6SUwQlr72MUSloySci2nM6Rdfc2A0cT4eGA= +github.com/changedenczd/dubbo-go-hessian2-dup-struct-name-test v0.0.3/go.mod h1:hDdmLYpL9E/pGzbUrBl5mWkibKysKDYaKVkC3CcWtcA= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dubbogo/gost v1.9.0 h1:UT+dWwvLyJiDotxJERO75jB3Yxgsdy10KztR5ycxRAk=