(dubbo-go-hessian2) tag v1.12.4 created (now c1070e1)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.12.4 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at c1070e1 (commit) No new revisions were added by this update.
(dubbo-go-hessian2) branch 1.12 updated (6c40744 -> c1070e1)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.12 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from 6c40744 release note for v1.12.3 add 5d34775 feat: support java null encoding add ebf53db refactor: remove config option and change null encoding to default support add 333dcbc Merge pull request #368 from ahaostudy/master add c1070e1 release note for v1.12.4 No new revisions were added by this update. Summary of changes: CHANGE.md | 5 encode.go | 9 +-- int.go | 2 +- null_test.go | 74 +- object_test.go | 6 + 5 files changed, 87 insertions(+), 9 deletions(-)
(dubbo-go-hessian2) branch master updated: release note for v1.12.4
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new c1070e1 release note for v1.12.4 c1070e1 is described below commit c1070e1c29cbb0a2c1b0911d3e62db921abe50d0 Author: tiltwind AuthorDate: Wed Nov 29 08:34:51 2023 +0800 release note for v1.12.4 --- CHANGE.md | 5 + 1 file changed, 5 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index 760d5fb..1969b69 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,10 @@ # Release Notes +## v1.12.4 + +### Bugfixes +- fix null encoding for nil pointer. [#368](https://github.com/apache/dubbo-go-hessian2/pull/368) + ## v1.12.3 ### Bugfixes
(dubbo-go-hessian2) tag v1.12.3 created (now 6c40744)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.12.3 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 6c40744 (commit) No new revisions were added by this update.
(dubbo-go-hessian2) branch 1.12 updated (f0fbe40 -> 6c40744)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.12 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from f0fbe40 release note for v1.12.2 add 4ce3eae fix: issue where Decoder panics when decoding an Object containing a Map with int8/int16 as key or value type add fbdccbe test: check if TestMapInObject decoded value is equal to original value add fb070d0 Merge pull request #366 from ahaostudy/master add 6c40744 release note for v1.12.3 No new revisions were added by this update. Summary of changes: CHANGE.md | 5 + map.go | 11 ++- map_test.go | 44 3 files changed, 59 insertions(+), 1 deletion(-)
(dubbo-go-hessian2) branch master updated: release note for v1.12.3
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 6c40744 release note for v1.12.3 6c40744 is described below commit 6c40744d34c228e5684b59c050e2085be8ac5a63 Author: tiltwind AuthorDate: Thu Nov 2 13:40:47 2023 +0800 release note for v1.12.3 --- CHANGE.md | 5 + 1 file changed, 5 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index 3eeec30..760d5fb 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,10 @@ # Release Notes +## v1.12.3 + +### Bugfixes +- fix Decoder failed to decode int8/int16 type values of map field in struct. [#366](https://github.com/apache/dubbo-go-hessian2/pull/366) + ## v1.12.2 ### Bugfixes
[dubbo-go-hessian2] tag v1.12.2 created (now f0fbe40)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.12.2 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at f0fbe40 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.12 updated (7231dc5 -> f0fbe40)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.12 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from 7231dc5 Merge branch 'master' into 1.12 add 9dc1a19 fix pointer value set add 64ed78d rename add 25f3ccf add commit add f73a225 add unit test for java wrapper object add f9c7f78 check CanSet first before set for same type add 8840018 Merge pull request #361 from wongoo/fix-ptr-value-set add f0fbe40 release note for v1.12.2 No new revisions were added by this update. Summary of changes: CHANGE.md | 5 + codec.go | 146 ++- date_test.go | 6 +- decode.go | 47 +++ java_lang.go | 4 +- java_lang_test.go | 49 +++ list.go| 2 +- object.go | 154 + object_test.go | 9 +- ref.go | 3 + .../src/main/java/test/TestCustomReply.java| 24 .../main/java/test/model/JavaLangObjectHolder.java | 98 + testcases/user/user_test.go| 1 + 13 files changed, 314 insertions(+), 234 deletions(-) create mode 100644 test_hessian/src/main/java/test/model/JavaLangObjectHolder.java
[dubbo-go-hessian2] branch master updated: release note for v1.12.2
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new f0fbe40 release note for v1.12.2 f0fbe40 is described below commit f0fbe40e207cc5ba0cb76b1dcc0c8db2aee877bf Author: tiltwind AuthorDate: Sat May 6 14:04:21 2023 +0800 release note for v1.12.2 --- CHANGE.md | 5 + 1 file changed, 5 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index ca475c0..3eeec30 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,10 @@ # Release Notes +## v1.12.2 + +### Bugfixes +- fix pointer value set. [#361](https://github.com/apache/dubbo-go-hessian2/pull/361) + ## v1.12.1 ### Bugfixes
[dubbo-go-hessian2] branch fix-ptr-value-set updated: check CanSet first before set for same type
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch fix-ptr-value-set in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/fix-ptr-value-set by this push: new f9c7f78 check CanSet first before set for same type f9c7f78 is described below commit f9c7f78ea0e0256ec503c8d7d020621e7e53f42a Author: tiltwind AuthorDate: Sat May 6 00:27:45 2023 +0800 check CanSet first before set for same type --- codec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec.go b/codec.go index adc55b8..466edb4 100644 --- a/codec.go +++ b/codec.go @@ -282,7 +282,7 @@ func SetValue(dest, v reflect.Value) { destType := dest.Type() // for most cases, the types are the same and can set the value directly. - if destType == vType { + if dest.CanSet() && destType == vType { dest.Set(v) return }
[dubbo-go-hessian2] branch fix-ptr-value-set created (now f73a225)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch fix-ptr-value-set in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at f73a225 add unit test for java wrapper object No new revisions were added by this update.
[dubbo-go-hessian2] tag v1.12.1 created (now 7231dc5)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.12.1 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 7231dc5 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch master updated (a55bacd -> 7231dc5)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from a55bacd release note for v1.12.1 add 2118b3d temp add 70f551e deprecated add 7557a5d mark array types deprected add 5a3a08b mark array types deprecated add 3ac5343 Merge branch 'mark_deprecated' into wrapper_type_dev add 9c35bf1 support wrapper types add 6697e3f support wrapper types 20230212 add 6ba7808 support wrapper types 20230212-2 add ec3010f reflect.PointerTo is supported only from go1.20, use a dummy variable to get the pointer type add faf63bf use reflect.Ptr add 94ce5f0 remove unused unit test add 76acae4 remove unused code & add license add a03ceac add java wrapper type support in readme add 6ea8710 Merge pull request #350 from wongoo/wrapper_type_dev add 2976f7b upgrade go to v1.17 to fix issue #348 for 2.0 branch (#353) add 7231dc5 Merge branch 'master' into 1.12 No new revisions were added by this update. Summary of changes: README.md | 48 +++--- array.go | 11 -- array_test.go | 142 codec.go | 87 +- const.go | 47 ++ decode_test.go | 7 +- encode.go | 5 + encode_test.go | 6 +- java_lang.go | 54 +++ java_lang_test.go | 178 + list.go| 58 --- object_test.go | 32 +++- output/output.go | 3 + output/testfuncs/{user.go => object.go}| 15 +- output/testfuncs/wrapper_class_array.go| 37 - pojo.go| 12 +- test_hessian/pom.xml | 2 +- test_hessian/src/main/java/test/Hessian.java | 3 + .../src/main/java/test/TestCustomReply.java| 97 ++- test_hessian/src/main/java/test/TestThrowable.java | 4 +- .../src/main/java/test/TestWrapperClassArray.java | 2 +- .../src/main/java/test/util/JavaHessianUtil.java | 77 + .../unit/{GoStringTest.java => GoObjectTest.java} | 14 +- .../test/java/unit/GoWrapperClassArrayTest.java| 15 +- 24 files changed, 797 insertions(+), 159 deletions(-) create mode 100644 java_lang.go create mode 100644 java_lang_test.go copy output/testfuncs/{user.go => object.go} (83%) create mode 100644 test_hessian/src/main/java/test/util/JavaHessianUtil.java copy test_hessian/src/test/java/unit/{GoStringTest.java => GoObjectTest.java} (74%)
[dubbo-go-hessian2] 01/01: Merge branch 'master' into 1.12
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch 1.12 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git commit 7231dc56dfe9384a1e41f0b76bf48aae125f338e Merge: 2976f7b a55bacd Author: tiltwind AuthorDate: Mon Apr 10 00:07:39 2023 +0800 Merge branch 'master' into 1.12 CHANGE.md | 10 ++ map.go | 2 +- ref.go | 29 +--- test_dubbo/pom.xml | 2 +- test_hessian/pom.xml| 2 +- testcases/issue356/issue356_test.go | 68 + 6 files changed, 98 insertions(+), 15 deletions(-)
[dubbo-go-hessian2] branch 1.12 updated (2976f7b -> 7231dc5)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.12 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from 2976f7b upgrade go to v1.17 to fix issue #348 for 2.0 branch (#353) add f13bb4e mark array types deprecated (#347) add 4cd8b9d Update README.md add f0ac0a6 upgrade go to v1.17 to fix issue #348 (#352) add 8390f13 Bump dubbo from 2.7.18 to 2.7.21 in /test_dubbo (#354) add 76ae75b Bump dubbo from 2.7.18 to 2.7.21 in /test_hessian (#355) add 33f7e9d fix issue 356 that ref to wrong type of map for nil value (#357) add a55bacd release note for v1.12.1 new 7231dc5 Merge branch 'master' into 1.12 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: CHANGE.md | 10 + map.go | 2 +- ref.go | 29 +++-- test_dubbo/pom.xml | 2 +- test_hessian/pom.xml | 2 +- .../user_test.go => issue356/issue356_test.go} | 47 +- 6 files changed, 59 insertions(+), 33 deletions(-) copy testcases/{user/user_test.go => issue356/issue356_test.go} (62%)
[dubbo-go-hessian2] branch master updated: release note for v1.12.1
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new a55bacd release note for v1.12.1 a55bacd is described below commit a55bacdfe4aa684f0bef4107a758d39f68e3bc8c Author: tiltwind AuthorDate: Mon Apr 10 00:07:08 2023 +0800 release note for v1.12.1 --- CHANGE.md | 10 ++ 1 file changed, 10 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index 9e6c769..ca475c0 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,15 @@ # Release Notes +## v1.12.1 + +### Bugfixes +- fix ref to wrong type of map for nil value. [#357](https://github.com/apache/dubbo-go-hessian2/pull/357) + +## v1.12.0 + +### New Features +- support java wrapper types. [#350](https://github.com/apache/dubbo-go-hessian2/pull/350) + ## v1.11.5 ### Bugfixes
[dubbo-go-hessian2] branch master updated: fix issue 356 that ref to wrong type of map for nil value (#357)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 33f7e9d fix issue 356 that ref to wrong type of map for nil value (#357) 33f7e9d is described below commit 33f7e9deb352bb7eccf305a806172ae52781b166 Author: tiltwind(斜风) <116183822+tiltw...@users.noreply.github.com> AuthorDate: Sun Apr 9 23:59:16 2023 +0800 fix issue 356 that ref to wrong type of map for nil value (#357) * fix issue 356 * fix issue 356 * fix issue 356 --- map.go | 2 +- ref.go | 29 +--- testcases/issue356/issue356_test.go | 68 + 3 files changed, 86 insertions(+), 13 deletions(-) diff --git a/map.go b/map.go index 1336756..f005324 100644 --- a/map.go +++ b/map.go @@ -117,7 +117,7 @@ func (e *Encoder) encMap(m interface{}) error { value = UnpackPtrValue(value) // check nil map - if value.Kind() == reflect.Ptr && !value.Elem().IsValid() { + if value.IsNil() || (value.Kind() == reflect.Ptr && !value.Elem().IsValid()) { e.buffer = EncNull(e.buffer) return nil } diff --git a/ref.go b/ref.go index f892601..0767ca0 100644 --- a/ref.go +++ b/ref.go @@ -29,6 +29,9 @@ import ( // Empty slice is not nil, but the addresses of all empty slice are the same. var _emptySliceAddr = unsafe.Pointer(reflect.ValueOf([]interface{}{}).Pointer()) +// The addresses of all nil map are the same. +var _nilMapAddr = unsafe.Pointer(reflect.ValueOf(map[interface{}]interface{}(nil)).Pointer()) + // used to ref object,list,map type _refElem struct { // record the kind of target, objects are the same only if the address and kind are the same @@ -127,20 +130,22 @@ func (e *Encoder) checkRefMap(v reflect.Value) (int, bool) { } } - if addr != _emptySliceAddr { - if elem, ok := e.refMap[addr]; ok { - if elem.kind == kind { - // If kind is not struct, just return the index. Otherwise, - // check whether the types are same, because the different - // empty struct may share the same address and kind. - if elem.kind != reflect.Struct { - return elem.index, ok - } else if elem.tp == tp { - return elem.index, ok - } + if addr == _emptySliceAddr || addr == _nilMapAddr { + return 0, false + } + + if elem, ok := e.refMap[addr]; ok { + if elem.kind == kind { + // If kind is not struct, just return the index. Otherwise, + // check whether the types are same, because the different + // empty struct may share the same address and kind. + if elem.kind != reflect.Struct { + return elem.index, ok + } else if elem.tp == tp { + return elem.index, ok } - return 0, false } + return 0, false } n := len(e.refMap) diff --git a/testcases/issue356/issue356_test.go b/testcases/issue356/issue356_test.go new file mode 100644 index 000..d6175d5 --- /dev/null +++ b/testcases/issue356/issue356_test.go @@ -0,0 +1,68 @@ +/* + * 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 issue356 + +import ( + "reflect" + "testing" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" +) + +import ( + "github.com/stretchr/testify/assert" +) + +type UserInfo struct { + Namestring + Address map[string]string + Family map[string]int +} + +func (UserInfo) JavaCla
[dubbo-go-hessian2] branch master updated: Bump dubbo from 2.7.18 to 2.7.21 in /test_hessian (#355)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 76ae75b Bump dubbo from 2.7.18 to 2.7.21 in /test_hessian (#355) 76ae75b is described below commit 76ae75b37ae4fc6bf213c664fe95cea40fe72514 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Wed Mar 15 16:36:08 2023 +0800 Bump dubbo from 2.7.18 to 2.7.21 in /test_hessian (#355) Bumps [dubbo](https://github.com/apache/dubbo) from 2.7.18 to 2.7.21. - [Release notes](https://github.com/apache/dubbo/releases) - [Changelog](https://github.com/apache/dubbo/blob/3.2/CHANGES.md) - [Commits](https://github.com/apache/dubbo/compare/dubbo-2.7.18...dubbo-2.7.21) --- updated-dependencies: - dependency-name: org.apache.dubbo:dubbo dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test_hessian/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_hessian/pom.xml b/test_hessian/pom.xml index 93a9824..4989f6d 100644 --- a/test_hessian/pom.xml +++ b/test_hessian/pom.xml @@ -45,7 +45,7 @@ org.apache.dubbo dubbo -2.7.18 +2.7.21 com.alibaba
[dubbo-go-hessian2] branch master updated (f0ac0a6 -> 8390f13)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from f0ac0a6 upgrade go to v1.17 to fix issue #348 (#352) add 8390f13 Bump dubbo from 2.7.18 to 2.7.21 in /test_dubbo (#354) No new revisions were added by this update. Summary of changes: test_dubbo/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[dubbo-go-hessian2] tag v1.12.0 created (now 2976f7b)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.12.0 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 2976f7b (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.12 created (now 2976f7b)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.12 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 2976f7b upgrade go to v1.17 to fix issue #348 for 2.0 branch (#353) No new revisions were added by this update.
[dubbo-go-hessian2] branch 2.0 updated (cf7a2db -> 2976f7b)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 2.0 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git discard cf7a2db change module path for v2 This update removed existing revisions from the reference, leaving the reference pointing at a previous point in the repository history. * -- * -- N refs/heads/2.0 (2976f7b) \ O -- O -- O (cf7a2db) Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[dubbo-go-hessian2] branch 2.0 updated: change module path for v2
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch 2.0 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/2.0 by this push: new cf7a2db change module path for v2 cf7a2db is described below commit cf7a2db72cdc165227a064b1a271e4339712fe31 Author: tiltwind AuthorDate: Sun Feb 26 11:09:45 2023 +0800 change module path for v2 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index be4814b..c4dcfd7 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/apache/dubbo-go-hessian2 +module github.com/apache/dubbo-go-hessian2/v2 require ( github.com/dubbogo/gost v1.13.1
[dubbo-go-hessian2] tag v2.0.0 created (now 2976f7b)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v2.0.0 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 2976f7b (commit) No new revisions were added by this update.
[dubbo-go-hessian2] tag v1.11.7 created (now f0ac0a6)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.11.7 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at f0ac0a6 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.11 updated (f13bb4e -> f0ac0a6)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.11 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from f13bb4e mark array types deprecated (#347) add 4cd8b9d Update README.md add f0ac0a6 upgrade go to v1.17 to fix issue #348 (#352) No new revisions were added by this update. Summary of changes: .github/workflows/github-actions.yml | 2 +- README.md| 2 +- date.go | 6 +++--- date_test.go | 16 4 files changed, 21 insertions(+), 5 deletions(-)
[dubbo-go-hessian2] branch 2.0 updated: upgrade go to v1.17 to fix issue #348 for 2.0 branch (#353)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch 2.0 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/2.0 by this push: new 2976f7b upgrade go to v1.17 to fix issue #348 for 2.0 branch (#353) 2976f7b is described below commit 2976f7bbd72e482546f6e00f4a7dd01d94cb11c8 Author: tiltwind(斜风) <116183822+tiltw...@users.noreply.github.com> AuthorDate: Fri Feb 24 21:24:47 2023 +0800 upgrade go to v1.17 to fix issue #348 for 2.0 branch (#353) * mark array types deprecated (#347) * mark array types deprected * mark array types deprecated * Update README.md change readme title * upgrade go to v1.17 to fix issue #348 - Co-authored-by: Xin.Zh --- .github/workflows/github-actions.yml | 2 +- README.md| 2 +- date.go | 6 +++--- date_test.go | 16 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 132f03e..0e304f5 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -19,7 +19,7 @@ jobs: os: - ubuntu-latest go_version: - - 1.13 + - 1.17 jdk_version: - 1.8 env: diff --git a/README.md b/README.md index d1867f2..0323622 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# gohessian +# dubbo-go-hessian2 [![Build Status](https://travis-ci.org/apache/dubbo-go-hessian2.png?branch=master)](https://travis-ci.org/apache/dubbo-go-hessian2) [![codecov](https://codecov.io/gh/apache/dubbo-go-hessian2/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/dubbo-go-hessian2) diff --git a/date.go b/date.go index 0b5329a..4fa6b25 100644 --- a/date.go +++ b/date.go @@ -42,12 +42,12 @@ func encDateInMs(b []byte, i interface{}) []byte { return append(b, BC_NULL) } b = append(b, BC_DATE) - return append(b, PackInt64(vi.UnixNano()/1e6)...) + return append(b, PackInt64(vi.UnixMilli())...) } -func encDateInMimute(b []byte, v time.Time) []byte { +func encDateInMinute(b []byte, v time.Time) []byte { b = append(b, BC_DATE_MINUTE) - return append(b, PackInt32(int32(v.UnixNano()/60e9))...) + return append(b, PackInt32(int32(v.Unix()/60))...) } / diff --git a/date_test.go b/date_test.go index f0a8b6f..2954ffc 100644 --- a/date_test.go +++ b/date_test.go @@ -66,6 +66,22 @@ func TestEncDate(t *testing.T) { d = NewDecoder(e.Buffer()) res, err = d.Decode() t.Logf("decode(%s, %s) = %v, %v\n", v, tz.Local(), res, err) + assert.Equal(t, tz.Local(), res) +} + +func TestEncDateIssue348(t *testing.T) { + e := NewEncoder() + v := "2914-02-09 06:15:23" + tz, _ := time.Parse("2006-01-02 15:04:05", v) + e.Encode(tz) + if len(e.Buffer()) == 0 { + t.Fail() + } + + d := NewDecoder(e.Buffer()) + res, err := d.Decode() + t.Logf("decode(%s, %s) = %v, %v\n", v, tz.Local(), res, err) + assert.Equal(t, tz.Local(), res) } func testDateFramework(t *testing.T, method string, expected time.Time) {
[dubbo-go-hessian2] branch master updated: upgrade go to v1.17 to fix issue #348 (#352)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new f0ac0a6 upgrade go to v1.17 to fix issue #348 (#352) f0ac0a6 is described below commit f0ac0a67b3e1e3e9b71131ffd1d2466b65875883 Author: tiltwind(斜风) <116183822+tiltw...@users.noreply.github.com> AuthorDate: Fri Feb 24 21:24:20 2023 +0800 upgrade go to v1.17 to fix issue #348 (#352) --- .github/workflows/github-actions.yml | 2 +- date.go | 6 +++--- date_test.go | 16 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 132f03e..0e304f5 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -19,7 +19,7 @@ jobs: os: - ubuntu-latest go_version: - - 1.13 + - 1.17 jdk_version: - 1.8 env: diff --git a/date.go b/date.go index 0b5329a..4fa6b25 100644 --- a/date.go +++ b/date.go @@ -42,12 +42,12 @@ func encDateInMs(b []byte, i interface{}) []byte { return append(b, BC_NULL) } b = append(b, BC_DATE) - return append(b, PackInt64(vi.UnixNano()/1e6)...) + return append(b, PackInt64(vi.UnixMilli())...) } -func encDateInMimute(b []byte, v time.Time) []byte { +func encDateInMinute(b []byte, v time.Time) []byte { b = append(b, BC_DATE_MINUTE) - return append(b, PackInt32(int32(v.UnixNano()/60e9))...) + return append(b, PackInt32(int32(v.Unix()/60))...) } / diff --git a/date_test.go b/date_test.go index f0a8b6f..2954ffc 100644 --- a/date_test.go +++ b/date_test.go @@ -66,6 +66,22 @@ func TestEncDate(t *testing.T) { d = NewDecoder(e.Buffer()) res, err = d.Decode() t.Logf("decode(%s, %s) = %v, %v\n", v, tz.Local(), res, err) + assert.Equal(t, tz.Local(), res) +} + +func TestEncDateIssue348(t *testing.T) { + e := NewEncoder() + v := "2914-02-09 06:15:23" + tz, _ := time.Parse("2006-01-02 15:04:05", v) + e.Encode(tz) + if len(e.Buffer()) == 0 { + t.Fail() + } + + d := NewDecoder(e.Buffer()) + res, err := d.Decode() + t.Logf("decode(%s, %s) = %v, %v\n", v, tz.Local(), res, err) + assert.Equal(t, tz.Local(), res) } func testDateFramework(t *testing.T, method string, expected time.Time) {
[dubbo-go-hessian2] tag v1.11.6 created (now f13bb4e)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.11.6 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at f13bb4e (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.11 updated (973d9f6 -> f13bb4e)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.11 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from 973d9f6 release note for v1.11.5 add 4820c03 Delete .travis.yml add f13bb4e mark array types deprecated (#347) No new revisions were added by this update. Summary of changes: .travis.yml | 32 array.go| 10 +- 2 files changed, 9 insertions(+), 33 deletions(-) delete mode 100644 .travis.yml
[dubbo-go-hessian2] branch 1.10 updated (a80067e -> f13bb4e)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.10 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from a80067e release note for v1.10.3 add cbc2ad9 support non-strict mode to decode object to map when unregistered add ef1946a fix lint check add 15f8430 build class definition from map keys add 641faae format code add 643d8c4 fix words add 150fbb3 add Strict Mode readme add f3f3a2e imporve unit test add ab8e186 Merge pull request #309 from wongoo/master add c18594c release note for v1.11.0 add bba95ec Bump dubbo from 2.7.11 to 2.7.15 in /test_dubbo (#314) add ca7b2ca Bump fastjson from 1.2.76 to 1.2.83 in /test_hessian (#316) add 12af60b Bump dubbo from 2.7.11 to 2.7.15 in /test_hessian add 411d2fc Merge pull request #315 from apache/dependabot/maven/test_hessian/org.apache.dubbo-dubbo-2.7.15 add 097671a nil slice decode to empty slice add 83d6845 Merge pull request #318 from mark4z/master add 31f2f96 if map is pojo, write class name first add 2437f11 add unit test(if map is pojo, write class name first) add 303698c Merge pull request #320 from zhengzepeng/master add 159280f release note for v1.11.1 add 4055e70 notify all ref holder at the end of decoding add 542bcf0 Merge pull request #324 from wongoo/fix-issue-323 add aa53824 add testing: TestDecodeCustomReplyEnumVariableList add 8529778 fix bug: support java enum variable list add bed48b1 Merge pull request #326 from shenchao861129/new-master add 868e06e Update object_test.go add e13beea revert-unexpected-merge (#329) add 0db9c6b fix bug: support java enum variable list (#330) add 1f1df01 release note for v1.11.2 add 5e88953 format code using gofmt -l -w . (#333) add d520464 Fix decode enum not correctly (#332) add cfbd9e1 release note for v1.11.3 add 1a36fa5 Bump dubbo from 2.7.15 to 2.7.18 in /test_dubbo add 67b078b Merge pull request #335 from apache/dependabot/maven/test_dubbo/org.apache.dubbo-dubbo-2.7.18 add 1e98ee0 Bump dubbo from 2.7.15 to 2.7.18 in /test_hessian add 901b071 Merge pull request #336 from apache/dependabot/maven/test_hessian/org.apache.dubbo-dubbo-2.7.18 add 801268e upgrade gost version to fix memory leak of AcquireBytes from https://github.com/dubbogo/gost/pull/108/files add e579dda Merge pull request #337 from apache/fix/AcquireBytes add a6671d5 mark dubbo2 rpc protocol implementation deprecated (#339) add 6455362 fix issue #340 (#341) add 973d9f6 release note for v1.11.5 add 4820c03 Delete .travis.yml add f13bb4e mark array types deprecated (#347) No new revisions were added by this update. Summary of changes: .github/workflows/github-actions.yml | 2 +- .travis.yml| 32 - CHANGE.md | 32 + README.md | 14 + array.go | 10 +- codec.go | 18 +- decode.go | 67 +- decode_test.go | 64 ++ encode.go | 12 +- go.mod | 4 +- go.sum | 691 - hessian.go | 22 +- hessian_test.go| 52 +- hessian_test/dup_struct_name_test.go | 14 - int.go | 2 +- java_collection.go | 2 +- java_exception/exception.go| 4 +- java_exception/interrupted_exception.go| 4 +- java_exception/interrupted_io_exception.go | 4 +- java_exception/lambda_conversion_exception.go | 4 +- java_exception/unmodifiable_class_exception.go | 4 +- java_sql_time.go | 14 +- java_unknown_exception.go | 2 +- java_unknown_exception_test.go | 4 +- java_util/uuid.go | 2 +- list.go| 39 +- list_test.go | 13 + map.go | 18 +- map_test.go| 12 + null.go| 4 +- object.go | 348 +++ object_test.go | 210 ++- pojo.go| 103 ++- ref.go | 27 +- request.go
[dubbo-go-hessian2] branch master updated: mark array types deprecated (#347)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new f13bb4e mark array types deprecated (#347) f13bb4e is described below commit f13bb4e83a904a0cfb90aabc7c9edf46fc7365dd Author: tiltwind(斜风) <116183822+tiltw...@users.noreply.github.com> AuthorDate: Tue Feb 14 09:44:49 2023 +0800 mark array types deprecated (#347) * mark array types deprected * mark array types deprecated --- array.go | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/array.go b/array.go index 30593d5..5a9c570 100644 --- a/array.go +++ b/array.go @@ -33,6 +33,7 @@ func init() { } // BooleanArray Boolean[] +// Deprecated: it will not be supported in next major version, being replaced by a slice type instead. type BooleanArray struct { Values []bool } @@ -60,7 +61,8 @@ func (*BooleanArray) JavaClassName() string { return "[java.lang.Boolean" } -// IntegerArray Integer[] +// IntegerArray Integer[]. +// Deprecated: it will not be supported in next major version, being replaced by a slice type instead. type IntegerArray struct { Values []int32 } @@ -89,6 +91,7 @@ func (*IntegerArray) JavaClassName() string { } // ByteArray Byte[] +// Deprecated: it will not be supported in next major version, being replaced by a slice type instead. type ByteArray struct { Values []uint8 } @@ -117,6 +120,7 @@ func (*ByteArray) JavaClassName() string { } // ShortArray Short[] +// Deprecated: it will not be supported in next major version, being replaced by a slice type instead. type ShortArray struct { Values []int16 } @@ -145,6 +149,7 @@ func (*ShortArray) JavaClassName() string { } // LongArray Long[] +// Deprecated: it will not be supported in next major version, being replaced by a slice type instead. type LongArray struct { Values []int64 } @@ -173,6 +178,7 @@ func (*LongArray) JavaClassName() string { } // FloatArray Float[] +// Deprecated: it will not be supported in next major version, being replaced by a slice type instead. type FloatArray struct { Values []float32 } @@ -201,6 +207,7 @@ func (*FloatArray) JavaClassName() string { } // DoubleArray Double[] +// Deprecated: it will not be supported in next major version, being replaced by a slice type instead. type DoubleArray struct { Values []float64 } @@ -229,6 +236,7 @@ func (*DoubleArray) JavaClassName() string { } // CharacterArray Character[] +// Deprecated: it will not be supported in next major version, being replaced by a slice type instead. type CharacterArray struct { Values string }
[dubbo-go-hessian2] branch 2.0 created (now 4820c03)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 2.0 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 4820c03 Delete .travis.yml No new revisions were added by this update.
[dubbo-go-hessian2] tag v1.11.5 created (now 973d9f6)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.11.5 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 973d9f6 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.11 updated (cfbd9e1 -> 973d9f6)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.11 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from cfbd9e1 release note for v1.11.3 add 1a36fa5 Bump dubbo from 2.7.15 to 2.7.18 in /test_dubbo add 67b078b Merge pull request #335 from apache/dependabot/maven/test_dubbo/org.apache.dubbo-dubbo-2.7.18 add 1e98ee0 Bump dubbo from 2.7.15 to 2.7.18 in /test_hessian add 901b071 Merge pull request #336 from apache/dependabot/maven/test_hessian/org.apache.dubbo-dubbo-2.7.18 add 801268e upgrade gost version to fix memory leak of AcquireBytes from https://github.com/dubbogo/gost/pull/108/files add e579dda Merge pull request #337 from apache/fix/AcquireBytes add a6671d5 mark dubbo2 rpc protocol implementation deprecated (#339) add 6455362 fix issue #340 (#341) add 973d9f6 release note for v1.11.5 No new revisions were added by this update. Summary of changes: CHANGE.md | 10 + go.mod | 4 +- go.sum | 691 - hessian.go | 4 + ref.go | 25 +- request.go | 4 + response.go| 4 + test_dubbo/pom.xml | 2 +- test_hessian/pom.xml | 2 +- .../user_test.go => issue340/issue340_test.go} | 70 ++- 10 files changed, 777 insertions(+), 39 deletions(-) copy testcases/{user/user_test.go => issue340/issue340_test.go} (53%)
[dubbo-go-hessian2] branch master updated: release note for v1.11.5
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 973d9f6 release note for v1.11.5 973d9f6 is described below commit 973d9f633ae1af98dfbb4b18aed59fe6bd46a345 Author: wongoo AuthorDate: Tue Dec 6 17:08:23 2022 +0800 release note for v1.11.5 --- CHANGE.md | 10 ++ 1 file changed, 10 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index c0d0c6c..9e6c769 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,15 @@ # Release Notes +## v1.11.5 + +### Bugfixes +- fix empty slice encode/decode error. [#341](https://github.com/apache/dubbo-go-hessian2/pull/341) + +## v1.11.4 + +### Bugfixes +- fix bytes.AcquireBytes memory leak by [dubbogo/gost](https://github.com/dubbogo/gost/pull/108) + ## v1.11.3 ### Bugfixes
[dubbo-go-hessian2] branch master updated: fix issue #340 (#341)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 6455362 fix issue #340 (#341) 6455362 is described below commit 64553626702bd1224f8709717594a13a1298cc10 Author: tiltwind(斜风) <116183822+tiltw...@users.noreply.github.com> AuthorDate: Tue Dec 6 16:57:48 2022 +0800 fix issue #340 (#341) * fix issue #340 * format code Co-authored-by: wongoo --- ref.go | 25 ++- testcases/issue340/issue340_test.go | 89 + 2 files changed, 104 insertions(+), 10 deletions(-) diff --git a/ref.go b/ref.go index e23d688..f892601 100644 --- a/ref.go +++ b/ref.go @@ -26,6 +26,9 @@ import ( perrors "github.com/pkg/errors" ) +// Empty slice is not nil, but the addresses of all empty slice are the same. +var _emptySliceAddr = unsafe.Pointer(reflect.ValueOf([]interface{}{}).Pointer()) + // used to ref object,list,map type _refElem struct { // record the kind of target, objects are the same only if the address and kind are the same @@ -124,18 +127,20 @@ func (e *Encoder) checkRefMap(v reflect.Value) (int, bool) { } } - if elem, ok := e.refMap[addr]; ok { - if elem.kind == kind { - // If kind is not struct, just return the index. Otherwise, - // check whether the types are same, because the different - // empty struct may share the same address and kind. - if elem.kind != reflect.Struct { - return elem.index, ok - } else if elem.tp == tp { - return elem.index, ok + if addr != _emptySliceAddr { + if elem, ok := e.refMap[addr]; ok { + if elem.kind == kind { + // If kind is not struct, just return the index. Otherwise, + // check whether the types are same, because the different + // empty struct may share the same address and kind. + if elem.kind != reflect.Struct { + return elem.index, ok + } else if elem.tp == tp { + return elem.index, ok + } } + return 0, false } - return 0, false } n := len(e.refMap) diff --git a/testcases/issue340/issue340_test.go b/testcases/issue340/issue340_test.go new file mode 100644 index 000..67d4218 --- /dev/null +++ b/testcases/issue340/issue340_test.go @@ -0,0 +1,89 @@ +/* + * 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 issue340 + +import ( + "reflect" + "testing" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" +) + +import ( + "github.com/stretchr/testify/assert" +) + +type Point struct { + X int + Y int +} + +func (Point) JavaClassName() string { + return "com.test.Point" +} + +type SpPoint struct { + X int + Y int + Sp int +} + +func (SpPoint) JavaClassName() string { + return "com.test.SpPoint" +} + +type ReqInfo struct { + Name string + Points []*Point + SpPoints []*SpPoint +} + +func (ReqInfo) JavaClassName() string { + return "com.test.ReqInfo" +} + +func TestIssue340Case(t *testing.T) { + req := { + Name: "test", + Points: []*Point{}, + SpPoints: []*SpPoint{}, + } + + hessian.RegisterPOJO({}) + hessian.RegisterPOJO({}) + hessian.RegisterPOJO(req) + + encoder := hessian.NewEncoder() + err := encoder.Encode(req) + if err != nil { + t.Error(err) + re
[dubbo-go-hessian2] branch master updated: mark dubbo2 rpc protocol implementation deprecated (#339)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new a6671d5 mark dubbo2 rpc protocol implementation deprecated (#339) a6671d5 is described below commit a6671d5098755d1133efe446a2b5f52b471dac22 Author: tiltwind(斜风) <116183822+tiltw...@users.noreply.github.com> AuthorDate: Tue Dec 6 16:57:07 2022 +0800 mark dubbo2 rpc protocol implementation deprecated (#339) Co-authored-by: wongoo --- hessian.go | 4 request.go | 4 response.go | 4 3 files changed, 12 insertions(+) diff --git a/hessian.go b/hessian.go index 0549984..231dbea 100644 --- a/hessian.go +++ b/hessian.go @@ -15,6 +15,10 @@ * limitations under the License. */ +// This file contains the implementation of +// [dubbo2 rpc protocol](https://dubbo.apache.org/zh/docs/concepts/rpc-protocol/#dubbo2), which is deprecated. +// Use the [implementation](https://github.com/apache/dubbo-go/tree/master/protocol/dubbo/hessian2) in dubbo-go project instead. + package hessian import ( diff --git a/request.go b/request.go index 7a50465..a6def73 100644 --- a/request.go +++ b/request.go @@ -15,6 +15,10 @@ * limitations under the License. */ +// This file contains the implementation of +// [dubbo2 rpc protocol](https://dubbo.apache.org/zh/docs/concepts/rpc-protocol/#dubbo2), which is deprecated. +// Use the [implementation](https://github.com/apache/dubbo-go/tree/master/protocol/dubbo/hessian2) in dubbo-go project instead. + package hessian import ( diff --git a/response.go b/response.go index 66235d7..5f90592 100644 --- a/response.go +++ b/response.go @@ -15,6 +15,10 @@ * limitations under the License. */ +// This file contains the implementation of +// [dubbo2 rpc protocol](https://dubbo.apache.org/zh/docs/concepts/rpc-protocol/#dubbo2), which is deprecated. +// Use the [implementation](https://github.com/apache/dubbo-go/tree/master/protocol/dubbo/hessian2) in dubbo-go project instead. + package hessian import (
[dubbo-go-hessian2] branch mark-deprecated created (now 6d1e6c0)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch mark-deprecated in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 6d1e6c0 mark dubbo2 rpc protocol implementation deprecated This branch includes the following new commits: new 6d1e6c0 mark dubbo2 rpc protocol implementation deprecated The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[dubbo-go-hessian2] 01/01: mark dubbo2 rpc protocol implementation deprecated
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch mark-deprecated in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git commit 6d1e6c0d717600410bc1bdb6e4262d4bff8603ff Author: wongoo AuthorDate: Sat Nov 19 16:47:39 2022 +0800 mark dubbo2 rpc protocol implementation deprecated --- hessian.go | 4 request.go | 4 response.go | 4 3 files changed, 12 insertions(+) diff --git a/hessian.go b/hessian.go index 0549984..231dbea 100644 --- a/hessian.go +++ b/hessian.go @@ -15,6 +15,10 @@ * limitations under the License. */ +// This file contains the implementation of +// [dubbo2 rpc protocol](https://dubbo.apache.org/zh/docs/concepts/rpc-protocol/#dubbo2), which is deprecated. +// Use the [implementation](https://github.com/apache/dubbo-go/tree/master/protocol/dubbo/hessian2) in dubbo-go project instead. + package hessian import ( diff --git a/request.go b/request.go index 7a50465..a6def73 100644 --- a/request.go +++ b/request.go @@ -15,6 +15,10 @@ * limitations under the License. */ +// This file contains the implementation of +// [dubbo2 rpc protocol](https://dubbo.apache.org/zh/docs/concepts/rpc-protocol/#dubbo2), which is deprecated. +// Use the [implementation](https://github.com/apache/dubbo-go/tree/master/protocol/dubbo/hessian2) in dubbo-go project instead. + package hessian import ( diff --git a/response.go b/response.go index 66235d7..5f90592 100644 --- a/response.go +++ b/response.go @@ -15,6 +15,10 @@ * limitations under the License. */ +// This file contains the implementation of +// [dubbo2 rpc protocol](https://dubbo.apache.org/zh/docs/concepts/rpc-protocol/#dubbo2), which is deprecated. +// Use the [implementation](https://github.com/apache/dubbo-go/tree/master/protocol/dubbo/hessian2) in dubbo-go project instead. + package hessian import (
[dubbo-go-hessian2] tag v1.11.3 created (now cfbd9e1)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.11.3 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at cfbd9e1 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.11 updated (1f1df01 -> cfbd9e1)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.11 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from 1f1df01 release note for v1.11.2 add 5e88953 format code using gofmt -l -w . (#333) add d520464 Fix decode enum not correctly (#332) add cfbd9e1 release note for v1.11.3 No new revisions were added by this update. Summary of changes: .github/workflows/github-actions.yml | 2 +- CHANGE.md | 6 +- array.go | 2 +- codec.go | 18 +- decode.go | 24 +-- hessian_test/dup_struct_name_test.go | 14 -- java_exception/exception.go| 4 +- java_exception/interrupted_exception.go| 4 +- java_exception/interrupted_io_exception.go | 4 +- java_exception/lambda_conversion_exception.go | 4 +- java_exception/unmodifiable_class_exception.go | 4 +- java_util/uuid.go | 2 +- list.go| 30 +-- null.go| 4 +- object.go | 210 +++-- object_test.go | 4 - pojo.go| 16 +- testcases/user/user.go | 87 + .../user/user_test.go | 49 +++-- 19 files changed, 291 insertions(+), 197 deletions(-) create mode 100644 testcases/user/user.go copy java_unknown_exception_test.go => testcases/user/user_test.go (53%)
[dubbo-go-hessian2] branch master updated: release note for v1.11.3
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new cfbd9e1 release note for v1.11.3 cfbd9e1 is described below commit cfbd9e10d7b685db84c0dc3f2f918cae5776f3af Author: wongoo AuthorDate: Mon Oct 31 17:06:25 2022 +0800 release note for v1.11.3 --- CHANGE.md | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGE.md b/CHANGE.md index 5abc0a2..c0d0c6c 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,12 +1,16 @@ # Release Notes +## v1.11.3 + +### Bugfixes +- fix java enum decoding incorrectly. [#332](https://github.com/apache/dubbo-go-hessian2/pull/332) + ## v1.11.2 ### Bugfixes - fix java enum variable list decoding error. [#330](https://github.com/apache/dubbo-go-hessian2/pull/330) - fix ref list is nil when decoding. [#324](https://github.com/apache/dubbo-go-hessian2/pull/324) - ## v1.11.1 ### Bugfixes
[dubbo-go-hessian2] branch master updated: Fix decode enum not correctly (#332)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new d520464 Fix decode enum not correctly (#332) d520464 is described below commit d520464544d64e8dc00278d38786d0264c6cf8c6 Author: 望哥 AuthorDate: Mon Oct 31 17:01:23 2022 +0800 Fix decode enum not correctly (#332) * fix enum decode * fix duplicate name struct unit test * add unit tests in sub directories * add unit test for type convert * format code * format import --- .github/workflows/github-actions.yml | 2 +- hessian_test/dup_struct_name_test.go | 14 -- object.go| 15 --- testcases/user/user.go | 87 testcases/user/user_test.go | 57 +++ 5 files changed, 154 insertions(+), 21 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 459f4f8..132f03e 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -80,7 +80,7 @@ jobs: run: golangci-lint run --timeout=10m -v - name: Go Test - run: GO111MODULE=on && go mod vendor && go test -race -v && go test -bench . -race -coverprofile=coverage.txt + run: GO111MODULE=on && go mod vendor && go test ./... -race -v && go test -bench . -race -coverprofile=coverage.txt - name: Coverage run: bash <(curl -s https://codecov.io/bash) diff --git a/hessian_test/dup_struct_name_test.go b/hessian_test/dup_struct_name_test.go index 14a0666..0c4954f 100644 --- a/hessian_test/dup_struct_name_test.go +++ b/hessian_test/dup_struct_name_test.go @@ -106,13 +106,6 @@ func TestDupStructNameResponse(t *testing.T) { assert.Nil(t, err) decodedResponse := {} - decodedResponse.RspObj = {} - err = codecR.ReadBody(decodedResponse) - assert.NotNil(t, err) - assert.Equal(t, ExpectedErrorMsg, err.Error()) - - decodedResponse = {} - decodedResponse.RspObj = {} err = codecR.ReadBody(decodedResponse) assert.Nil(t, err) @@ -134,13 +127,6 @@ func TestDupStructNameResponse2(t *testing.T) { assert.Nil(t, err) decodedResponse := {} - decodedResponse.RspObj = {} - err = codecR.ReadBody(decodedResponse) - assert.NotNil(t, err) - assert.Equal(t, ExpectedErrorMsg, err.Error()) - - decodedResponse = {} - decodedResponse.RspObj = {} err = codecR.ReadBody(decodedResponse) assert.Nil(t, err) diff --git a/object.go b/object.go index 3d16043..f5898cf 100644 --- a/object.go +++ b/object.go @@ -508,17 +508,20 @@ func (d *Decoder) decInstance(typ reflect.Type, cls *ClassInfo) (interface{}, er if err != nil { // java enum if fldRawValue.Type().Implements(javaEnumType) { - d.unreadByte() // Enum parsing, decInt64 above has read a byte, so you need to return a byte here - s, decErr := d.DecodeValue() + _ = d.unreadByte() // Enum parsing, decInt64 above has read a byte, so you need to return a byte here + enumVal, decErr := d.DecodeValue() if decErr != nil { return nil, perrors.Wrapf(decErr, "decInstance->decObject field name:%s", fieldName) } - enumValue, _ := s.(JavaEnum) - num = int32(enumValue) - } else { - return nil, perrors.Wrapf(err, "decInstance->decInt32, field name:%s", fieldName) + + SetValue(fldRawValue, reflect.ValueOf(enumVal)) + + continue } + + return nil, perrors.Wrapf(err, "decInstance->decInt32, field name:%s", fieldName) } + fldRawValue.SetInt(int64(num)) case reflect.Uint16, reflect.Uint8: num, err := d.decInt32(TAG_READ) diff --git a/testcases/user/user.go b/testcases/user/user.go new file mode 100644 index 000..888951b --- /dev/null +++ b/testcases/user/user.go @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional informa
[dubbo-go-hessian2] branch master updated: format code using gofmt -l -w . (#333)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 5e88953 format code using gofmt -l -w . (#333) 5e88953 is described below commit 5e88953d672c895040e559925559f834cd2203af Author: 望哥 AuthorDate: Sat Oct 29 15:14:10 2022 +0800 format code using gofmt -l -w . (#333) --- array.go | 2 +- codec.go | 18 +-- decode.go | 24 +-- java_exception/exception.go| 4 +- java_exception/interrupted_exception.go| 4 +- java_exception/interrupted_io_exception.go | 4 +- java_exception/lambda_conversion_exception.go | 4 +- java_exception/unmodifiable_class_exception.go | 4 +- java_util/uuid.go | 2 +- list.go| 30 ++-- null.go| 4 +- object.go | 195 + object_test.go | 4 - pojo.go| 16 +- 14 files changed, 159 insertions(+), 156 deletions(-) diff --git a/array.go b/array.go index 1376a7a..30593d5 100644 --- a/array.go +++ b/array.go @@ -60,7 +60,7 @@ func (*BooleanArray) JavaClassName() string { return "[java.lang.Boolean" } -//IntegerArray Integer[] +// IntegerArray Integer[] type IntegerArray struct { Values []int32 } diff --git a/codec.go b/codec.go index 161bf11..bfe7f10 100644 --- a/codec.go +++ b/codec.go @@ -75,7 +75,7 @@ func PackInt8(v int8, b []byte) []byte { } // PackInt16 packs int16 to byte array -//[10].pack('N').bytes => [0, 0, 0, 10] +// [10].pack('N').bytes => [0, 0, 0, 10] func PackInt16(v int16) []byte { var array [2]byte binary.BigEndian.PutUint16(array[:2], uint16(v)) @@ -83,7 +83,7 @@ func PackInt16(v int16) []byte { } // PackUint16 packs uint16 to byte array -//[10].pack('N').bytes => [0, 0, 0, 10] +// [10].pack('N').bytes => [0, 0, 0, 10] func PackUint16(v uint16) []byte { var array [2]byte binary.BigEndian.PutUint16(array[:2], v) @@ -91,7 +91,7 @@ func PackUint16(v uint16) []byte { } // PackInt32 packs int32 to byte array -//[10].pack('N').bytes => [0, 0, 0, 10] +// [10].pack('N').bytes => [0, 0, 0, 10] func PackInt32(v int32) []byte { var array [4]byte binary.BigEndian.PutUint32(array[:4], uint32(v)) @@ -99,7 +99,7 @@ func PackInt32(v int32) []byte { } // PackInt64 packs int64 to byte array -//[10].pack('q>').bytes => [0, 0, 0, 0, 0, 0, 0, 10] +// [10].pack('q>').bytes => [0, 0, 0, 0, 0, 0, 0, 10] func PackInt64(v int64) []byte { var array [8]byte binary.BigEndian.PutUint64(array[:8], uint64(v)) @@ -107,7 +107,7 @@ func PackInt64(v int64) []byte { } // PackFloat64 packs float64 to byte array -//[10].pack('G').bytes => [64, 36, 0, 0, 0, 0, 0, 0] +// [10].pack('G').bytes => [64, 36, 0, 0, 0, 0, 0, 0] // PackFloat64 invokes go's official math library function Float64bits. func PackFloat64(v float64) []byte { var array [8]byte @@ -116,21 +116,21 @@ func PackFloat64(v float64) []byte { } // UnpackInt16 unpacks int16 from byte array -//(0,2).unpack('n') +// (0,2).unpack('n') func UnpackInt16(b []byte) int16 { arr := b[:2] return int16(binary.BigEndian.Uint16(arr)) } // UnpackUint16 unpacks int16 from byte array -//(0,2).unpack('n') +// (0,2).unpack('n') func UnpackUint16(b []byte) uint16 { arr := b[:2] return binary.BigEndian.Uint16(arr) } // UnpackInt32 unpacks int32 from byte array -//(0,4).unpack('N') +// (0,4).unpack('N') func UnpackInt32(b []byte) int32 { arr := b[:4] return int32(binary.BigEndian.Uint32(arr)) @@ -450,7 +450,7 @@ func ConvertSliceValueType(destTyp reflect.Type, v reflect.Value) (reflect.Value return sl, nil } -//PackPtrInterface pack struct interface to pointer interface +// PackPtrInterface pack struct interface to pointer interface func PackPtrInterface(s interface{}, value reflect.Value) interface{} { vv := reflect.New(reflect.TypeOf(s)) vv.Elem().Set(value) diff --git a/decode.go b/decode.go index 0e7932e..13d2a3c 100644 --- a/decode.go +++ b/decode.go @@ -89,17 +89,17 @@ func NewDecoderWithSkip(b []byte) *Decoder { // only for cache pool, before decode Reset should be called. // For example, with pooling use, will effectively improve performance // -// var hessianPool = { -// New: func() interface{} { -// return hessian.NewCheapDecoderWithSkip([]byte{}) -// }, -// } +// var hessianPool = { +// New: func() interf
[dubbo-go-hessian2] tag v1.11.2 created (now 1f1df01)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.11.2 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 1f1df01 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.11 updated (159280f -> 1f1df01)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.11 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from 159280f release note for v1.11.1 add 4055e70 notify all ref holder at the end of decoding add 542bcf0 Merge pull request #324 from wongoo/fix-issue-323 add aa53824 add testing: TestDecodeCustomReplyEnumVariableList add 8529778 fix bug: support java enum variable list add bed48b1 Merge pull request #326 from shenchao861129/new-master add 868e06e Update object_test.go add e13beea revert-unexpected-merge (#329) add 0db9c6b fix bug: support java enum variable list (#330) add 1f1df01 release note for v1.11.2 No new revisions were added by this update. Summary of changes: CHANGE.md | 7 +++ decode.go | 16 -- decode_test.go | 54 list.go| 2 - object.go | 7 +-- object_test.go | 57 ++ ref.go | 2 + .../src/main/java/test/TestCustomReply.java| 9 8 files changed, 146 insertions(+), 8 deletions(-)
[dubbo-go-hessian2] branch master updated: release note for v1.11.2
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 1f1df01 release note for v1.11.2 1f1df01 is described below commit 1f1df01f2535dcdfcd8d49b6e0c8e87634a991a3 Author: wongoo AuthorDate: Mon Oct 24 11:24:51 2022 +0800 release note for v1.11.2 --- CHANGE.md | 7 +++ 1 file changed, 7 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index ad52d6c..5abc0a2 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,12 @@ # Release Notes +## v1.11.2 + +### Bugfixes +- fix java enum variable list decoding error. [#330](https://github.com/apache/dubbo-go-hessian2/pull/330) +- fix ref list is nil when decoding. [#324](https://github.com/apache/dubbo-go-hessian2/pull/324) + + ## v1.11.1 ### Bugfixes
[dubbo-go-hessian2] branch master updated: fix bug: support java enum variable list (#330)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 0db9c6b fix bug: support java enum variable list (#330) 0db9c6b is described below commit 0db9c6b3e27301bf5b49b3f37643705065e345bb Author: shenchao861129 AuthorDate: Mon Oct 24 08:49:27 2022 +0800 fix bug: support java enum variable list (#330) Co-authored-by: shenchao --- list.go| 2 - object.go | 7 +-- object_test.go | 57 ++ .../src/main/java/test/TestCustomReply.java| 9 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/list.go b/list.go index 0ce242b..af60860 100644 --- a/list.go +++ b/list.go @@ -380,8 +380,6 @@ func (d *Decoder) readTypedListValue(length int, listTyp string, isVariableArr b } else { if it != nil { aryValue.Index(j).Set(EnsureRawValue(it)) - } else { - SetValue(aryValue.Index(j), EnsureRawValue(it)) } } } diff --git a/object.go b/object.go index 54526ae..ab46987 100644 --- a/object.go +++ b/object.go @@ -660,7 +660,7 @@ func (d *Decoder) getStructDefByIndex(idx int) (reflect.Type, *ClassInfo, error) return s.typ, cls, nil } -func (d *Decoder) decEnum(javaName string, flag int32) (JavaEnum, error) { +func (d *Decoder) decEnum(javaName string, flag int32) (interface{}, error) { var ( err error enumName string @@ -678,8 +678,9 @@ func (d *Decoder) decEnum(javaName string, flag int32) (JavaEnum, error) { } enumValue = info.inst.(POJOEnum).EnumValue(enumName) - d.appendRefs(enumValue) - return enumValue, nil + enumVal := PackPtr(reflect.ValueOf(enumValue).Convert(info.typ)).Interface() + d.appendRefs(enumVal) + return enumVal, nil } // skip this object diff --git a/object_test.go b/object_test.go index b7afa11..7006849 100644 --- a/object_test.go +++ b/object_test.go @@ -21,6 +21,7 @@ import ( "encoding/json" "math" "reflect" + "strconv" "testing" "time" @@ -1061,3 +1062,59 @@ func TestDecodeSliceIntegerHasNull(t *testing.T) { RegisterPOJO({}) testDecodeFramework(t, "customReplyTypedListIntegerHasNull", {Id: 0, List: []int32{1, 0}}) } + +func TestDecodeCustomReplyEnumVariableList(t *testing.T) { + for v := range _LocaleCategoryEnumValues { + RegisterJavaEnum(v) + } + + got, err := decodeJavaResponse(`customReplyEnumVariableList`, ``, false) + assert.NoError(t, err) + t.Logf("customReplyEnumVariableList %T %+v", got, got) + enumList, ok := got.([]*LocaleCategoryEnum) + if !ok { + t.Errorf("expect []LocaleCategoryEnum, but get %v", got) + return + } + assert.Equal(t, LocaleCategoryEnumDisplay, *enumList[0]) + assert.Nil(t, enumList[1]) + assert.Equal(t, LocaleCategoryEnumFormat, *enumList[2]) +} + +const ( + LocaleCategoryEnumDisplay LocaleCategoryEnum = iota + LocaleCategoryEnumFormat +) + +var ( + _LocaleCategoryEnumValues = map[LocaleCategoryEnum]string{ + LocaleCategoryEnumDisplay: "DISPLAY", + LocaleCategoryEnumFormat: "FORMAT", + } + _LocaleCategoryEnumEntities = map[string]LocaleCategoryEnum{ + "DISPLAY": LocaleCategoryEnumDisplay, + "FORMAT": LocaleCategoryEnumFormat, + } +) + +type LocaleCategoryEnum JavaEnum + +func (e LocaleCategoryEnum) JavaClassName() string { + return "java.util.Locale$Category" +} + +func (e LocaleCategoryEnum) String() string { + if v, ok := _LocaleCategoryEnumValues[e]; ok { + return v + } + + return strconv.Itoa(int(e)) +} + +func (e LocaleCategoryEnum) EnumValue(s string) JavaEnum { + if v, ok := _LocaleCategoryEnumEntities[s]; ok { + return JavaEnum(v) + } + + return InvalidJavaEnum +} diff --git a/test_hessian/src/main/java/test/TestCustomReply.java b/test_hessian/src/main/java/test/TestCustomReply.java index 8d22362..2a28037 100644 --- a/test_hessian/src/main/java/test/TestCustomReply.java +++ b/test_hessian/src/main/java/test/TestCustomReply.java @@ -693,6 +693,15 @@ public class TestCustomReply { output.writeObject(map); output.flush(); } + +public void customReplyEnumVariableList() throws Exception { +List enumList =
[dubbo-go-hessian2] branch master updated: revert-unexpected-merge (#329)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new e13beea revert-unexpected-merge (#329) e13beea is described below commit e13beea6e44ba7fe3f53273f41015b4e4ad998da Author: 望哥 AuthorDate: Sun Oct 23 12:12:01 2022 +0800 revert-unexpected-merge (#329) --- list.go| 4 -- object_test.go | 52 -- .../src/main/java/test/TestCustomReply.java| 9 3 files changed, 65 deletions(-) diff --git a/list.go b/list.go index 5bcbb95..0ce242b 100644 --- a/list.go +++ b/list.go @@ -120,10 +120,6 @@ func getListType(javalistname string) reflect.Type { } tp := tpStructInfo.typ - // if tp is enum, return nil - if tp.Implements(javaEnumType) { - return nil - } if tp.Kind() != reflect.Ptr { tp = reflect.New(tp).Type() } diff --git a/object_test.go b/object_test.go index 748e038..b7afa11 100644 --- a/object_test.go +++ b/object_test.go @@ -21,7 +21,6 @@ import ( "encoding/json" "math" "reflect" - "strconv" "testing" "time" @@ -1062,54 +1061,3 @@ func TestDecodeSliceIntegerHasNull(t *testing.T) { RegisterPOJO({}) testDecodeFramework(t, "customReplyTypedListIntegerHasNull", {Id: 0, List: []int32{1, 0}}) } - -func TestDecodeCustomReplyEnumVariableList(t *testing.T) { - for v := range _LocaleCategoryEnumValues { - RegisterJavaEnum(v) - } - - got, err := decodeJavaResponse(`customReplyEnumVariableList`, ``, false) - assert.NoError(t, err) - t.Logf("%T %+v", got, got) - el := []interface{}{JavaEnum(0), nil, JavaEnum(1)} - assert.True(t, reflect.DeepEqual(got, el)) -} - -const ( - LocaleCategoryEnumDisplay LocaleCategoryEnum = iota - LocaleCategoryEnumFormat -) - -var ( - _LocaleCategoryEnumValues = map[LocaleCategoryEnum]string{ - LocaleCategoryEnumDisplay: "DISPLAY", - LocaleCategoryEnumFormat: "FORMAT", -} - -_LocaleCategoryEnumEntities = map[string]LocaleCategoryEnum{ - "DISPLAY": LocaleCategoryEnumDisplay, - "FORMAT": LocaleCategoryEnumFormat, -} -) - -type LocaleCategoryEnum JavaEnum - -func (e LocaleCategoryEnum) JavaClassName() string { - return "java.util.Locale$Category" -} - -func (e LocaleCategoryEnum) String() string { - if v, ok := _LocaleCategoryEnumValues[e]; ok { - return v - } - - return strconv.Itoa(int(e)) -} - -func (e LocaleCategoryEnum) EnumValue(s string) JavaEnum { - if v, ok := _LocaleCategoryEnumEntities[s]; ok { - return JavaEnum(v) - } - - return InvalidJavaEnum -} diff --git a/test_hessian/src/main/java/test/TestCustomReply.java b/test_hessian/src/main/java/test/TestCustomReply.java index 2a28037..8d22362 100644 --- a/test_hessian/src/main/java/test/TestCustomReply.java +++ b/test_hessian/src/main/java/test/TestCustomReply.java @@ -693,15 +693,6 @@ public class TestCustomReply { output.writeObject(map); output.flush(); } - -public void customReplyEnumVariableList() throws Exception { -List enumList = new ArrayList<>(); -enumList.add(Locale.Category.DISPLAY); -enumList.add(null); -enumList.add(Locale.Category.FORMAT); -output.writeObject(enumList.toArray(new Locale.Category[enumList.size()])); -output.flush(); -} } interface Leg {
[dubbo-go-hessian2] 01/01: revert-unexpected-merge
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch revert-unexpected-merge in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git commit 05cf95b6cd002eaebbd65e5fc543e3010148fce6 Author: wongoo AuthorDate: Sun Oct 23 11:56:35 2022 +0800 revert-unexpected-merge --- list.go| 4 -- object_test.go | 52 -- .../src/main/java/test/TestCustomReply.java| 9 3 files changed, 65 deletions(-) diff --git a/list.go b/list.go index 5bcbb95..0ce242b 100644 --- a/list.go +++ b/list.go @@ -120,10 +120,6 @@ func getListType(javalistname string) reflect.Type { } tp := tpStructInfo.typ - // if tp is enum, return nil - if tp.Implements(javaEnumType) { - return nil - } if tp.Kind() != reflect.Ptr { tp = reflect.New(tp).Type() } diff --git a/object_test.go b/object_test.go index 748e038..b7afa11 100644 --- a/object_test.go +++ b/object_test.go @@ -21,7 +21,6 @@ import ( "encoding/json" "math" "reflect" - "strconv" "testing" "time" @@ -1062,54 +1061,3 @@ func TestDecodeSliceIntegerHasNull(t *testing.T) { RegisterPOJO({}) testDecodeFramework(t, "customReplyTypedListIntegerHasNull", {Id: 0, List: []int32{1, 0}}) } - -func TestDecodeCustomReplyEnumVariableList(t *testing.T) { - for v := range _LocaleCategoryEnumValues { - RegisterJavaEnum(v) - } - - got, err := decodeJavaResponse(`customReplyEnumVariableList`, ``, false) - assert.NoError(t, err) - t.Logf("%T %+v", got, got) - el := []interface{}{JavaEnum(0), nil, JavaEnum(1)} - assert.True(t, reflect.DeepEqual(got, el)) -} - -const ( - LocaleCategoryEnumDisplay LocaleCategoryEnum = iota - LocaleCategoryEnumFormat -) - -var ( - _LocaleCategoryEnumValues = map[LocaleCategoryEnum]string{ - LocaleCategoryEnumDisplay: "DISPLAY", - LocaleCategoryEnumFormat: "FORMAT", -} - -_LocaleCategoryEnumEntities = map[string]LocaleCategoryEnum{ - "DISPLAY": LocaleCategoryEnumDisplay, - "FORMAT": LocaleCategoryEnumFormat, -} -) - -type LocaleCategoryEnum JavaEnum - -func (e LocaleCategoryEnum) JavaClassName() string { - return "java.util.Locale$Category" -} - -func (e LocaleCategoryEnum) String() string { - if v, ok := _LocaleCategoryEnumValues[e]; ok { - return v - } - - return strconv.Itoa(int(e)) -} - -func (e LocaleCategoryEnum) EnumValue(s string) JavaEnum { - if v, ok := _LocaleCategoryEnumEntities[s]; ok { - return JavaEnum(v) - } - - return InvalidJavaEnum -} diff --git a/test_hessian/src/main/java/test/TestCustomReply.java b/test_hessian/src/main/java/test/TestCustomReply.java index 2a28037..8d22362 100644 --- a/test_hessian/src/main/java/test/TestCustomReply.java +++ b/test_hessian/src/main/java/test/TestCustomReply.java @@ -693,15 +693,6 @@ public class TestCustomReply { output.writeObject(map); output.flush(); } - -public void customReplyEnumVariableList() throws Exception { -List enumList = new ArrayList<>(); -enumList.add(Locale.Category.DISPLAY); -enumList.add(null); -enumList.add(Locale.Category.FORMAT); -output.writeObject(enumList.toArray(new Locale.Category[enumList.size()])); -output.flush(); -} } interface Leg {
[dubbo-go-hessian2] branch revert-unexpected-merge created (now 05cf95b)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch revert-unexpected-merge in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 05cf95b revert-unexpected-merge This branch includes the following new commits: new 05cf95b revert-unexpected-merge The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[dubbo-go-hessian2] branch revert-326-new-master updated (4535a56 -> 4055e70)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch revert-326-new-master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git discard 4535a56 Revert "add testing: TestDecodeCustomReplyEnumVariableList" omit bed48b1 Merge pull request #326 from shenchao861129/new-master omit 8529778 fix bug: support java enum variable list omit aa53824 add testing: TestDecodeCustomReplyEnumVariableList omit 542bcf0 Merge pull request #324 from wongoo/fix-issue-323 This update removed existing revisions from the reference, leaving the reference pointing at a previous point in the repository history. * -- * -- N refs/heads/revert-326-new-master (4055e70) \ O -- O -- O (4535a56) Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes:
[dubbo-go-hessian2] branch revert-326-new-master created (now 4535a56)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch revert-326-new-master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 4535a56 Revert "add testing: TestDecodeCustomReplyEnumVariableList" This branch includes the following new commits: new 4535a56 Revert "add testing: TestDecodeCustomReplyEnumVariableList" The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[dubbo-go-hessian2] 01/01: Revert "add testing: TestDecodeCustomReplyEnumVariableList"
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch revert-326-new-master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git commit 4535a56dd3f11138e5dfaaded84a8e6897de45ae Author: 望哥 <89767...@qq.com> AuthorDate: Sun Oct 23 11:22:50 2022 +0800 Revert "add testing: TestDecodeCustomReplyEnumVariableList" --- list.go| 4 -- object_test.go | 50 -- .../src/main/java/test/TestCustomReply.java| 9 3 files changed, 63 deletions(-) diff --git a/list.go b/list.go index 5bcbb95..0ce242b 100644 --- a/list.go +++ b/list.go @@ -120,10 +120,6 @@ func getListType(javalistname string) reflect.Type { } tp := tpStructInfo.typ - // if tp is enum, return nil - if tp.Implements(javaEnumType) { - return nil - } if tp.Kind() != reflect.Ptr { tp = reflect.New(tp).Type() } diff --git a/object_test.go b/object_test.go index 1903a8d..b7afa11 100644 --- a/object_test.go +++ b/object_test.go @@ -21,7 +21,6 @@ import ( "encoding/json" "math" "reflect" - "strconv" "testing" "time" @@ -1062,52 +1061,3 @@ func TestDecodeSliceIntegerHasNull(t *testing.T) { RegisterPOJO({}) testDecodeFramework(t, "customReplyTypedListIntegerHasNull", {Id: 0, List: []int32{1, 0}}) } - -func TestDecodeCustomReplyEnumVariableList(t *testing.T) { - for v := range _LocaleCategoryEnumValues { - RegisterJavaEnum(v) - } - - got, err := decodeJavaResponse(`customReplyEnumVariableList`, ``, false) - assert.NoError(t, err) - t.Logf("%T %+v", got, got) - el := []interface{}{JavaEnum(0), nil, JavaEnum(1)} - assert.True(t, reflect.DeepEqual(got, el)) -} - -const ( - LocaleCategoryEnumDisplay LocaleCategoryEnum = iota - LocaleCategoryEnumFormat -) - -var _LocaleCategoryEnumValues = map[LocaleCategoryEnum]string{ - LocaleCategoryEnumDisplay: "DISPLAY", - LocaleCategoryEnumFormat: "FORMAT", -} - -var _LocaleCategoryEnumEntities = map[string]LocaleCategoryEnum{ - "DISPLAY": LocaleCategoryEnumDisplay, - "FORMAT": LocaleCategoryEnumFormat, -} - -type LocaleCategoryEnum JavaEnum - -func (e LocaleCategoryEnum) JavaClassName() string { - return "java.util.Locale$Category" -} - -func (e LocaleCategoryEnum) String() string { - if v, ok := _LocaleCategoryEnumValues[e]; ok { - return v - } - - return strconv.Itoa(int(e)) -} - -func (e LocaleCategoryEnum) EnumValue(s string) JavaEnum { - if v, ok := _LocaleCategoryEnumEntities[s]; ok { - return JavaEnum(v) - } - - return InvalidJavaEnum -} diff --git a/test_hessian/src/main/java/test/TestCustomReply.java b/test_hessian/src/main/java/test/TestCustomReply.java index 2a28037..8d22362 100644 --- a/test_hessian/src/main/java/test/TestCustomReply.java +++ b/test_hessian/src/main/java/test/TestCustomReply.java @@ -693,15 +693,6 @@ public class TestCustomReply { output.writeObject(map); output.flush(); } - -public void customReplyEnumVariableList() throws Exception { -List enumList = new ArrayList<>(); -enumList.add(Locale.Category.DISPLAY); -enumList.add(null); -enumList.add(Locale.Category.FORMAT); -output.writeObject(enumList.toArray(new Locale.Category[enumList.size()])); -output.flush(); -} } interface Leg {
[dubbo-go-hessian2] tag v1.11.1 created (now 159280f)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.11.1 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git at 159280f (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.11 updated (c18594c -> 159280f)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.11 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from c18594c release note for v1.11.0 add bba95ec Bump dubbo from 2.7.11 to 2.7.15 in /test_dubbo (#314) add ca7b2ca Bump fastjson from 1.2.76 to 1.2.83 in /test_hessian (#316) add 12af60b Bump dubbo from 2.7.11 to 2.7.15 in /test_hessian add 411d2fc Merge pull request #315 from apache/dependabot/maven/test_hessian/org.apache.dubbo-dubbo-2.7.15 add 097671a nil slice decode to empty slice add 83d6845 Merge pull request #318 from mark4z/master add 31f2f96 if map is pojo, write class name first add 2437f11 add unit test(if map is pojo, write class name first) add 303698c Merge pull request #320 from zhengzepeng/master add 159280f release note for v1.11.1 No new revisions were added by this update. Summary of changes: CHANGE.md | 6 ++ list.go | 7 ++- list_test.go | 13 + map.go| 9 - map_test.go | 12 test_dubbo/pom.xml| 2 +- test_hessian/pom.xml | 4 ++-- test_hessian/src/main/java/test/TestCustomDecode.java | 9 + 8 files changed, 57 insertions(+), 5 deletions(-)
[dubbo-go-hessian2] branch master updated: release note for v1.11.1
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 159280f release note for v1.11.1 159280f is described below commit 159280f0a173eea31a1abe2da257438fff508e14 Author: wongoo AuthorDate: Fri Jul 22 18:54:28 2022 +0800 release note for v1.11.1 --- CHANGE.md | 6 ++ 1 file changed, 6 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index 7171f69..ad52d6c 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,11 @@ # Release Notes +## v1.11.1 + +### Bugfixes +- fix not writing class name first when encoding pojo map. [#320](https://github.com/apache/dubbo-go-hessian2/pull/320) +- fix nil slice decoding to empty slice. [#318](https://github.com/apache/dubbo-go-hessian2/pull/318) + ## v1.11.0 ### New Features
[dubbo-go-hessian2] branch master updated: Bump fastjson from 1.2.76 to 1.2.83 in /test_hessian (#316)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new ca7b2ca Bump fastjson from 1.2.76 to 1.2.83 in /test_hessian (#316) ca7b2ca is described below commit ca7b2cabc106bfae66f8e08665162fee2e69c265 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Fri Jun 17 11:59:44 2022 +0800 Bump fastjson from 1.2.76 to 1.2.83 in /test_hessian (#316) Bumps [fastjson](https://github.com/alibaba/fastjson) from 1.2.76 to 1.2.83. - [Release notes](https://github.com/alibaba/fastjson/releases) - [Commits](https://github.com/alibaba/fastjson/compare/1.2.76...1.2.83) --- updated-dependencies: - dependency-name: com.alibaba:fastjson dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test_hessian/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_hessian/pom.xml b/test_hessian/pom.xml index 9074471..12b2111 100644 --- a/test_hessian/pom.xml +++ b/test_hessian/pom.xml @@ -50,7 +50,7 @@ com.alibaba fastjson -1.2.76 +1.2.83 junit
[dubbo-go-hessian2] branch master updated (c18594c -> bba95ec)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git from c18594c release note for v1.11.0 add bba95ec Bump dubbo from 2.7.11 to 2.7.15 in /test_dubbo (#314) No new revisions were added by this update. Summary of changes: test_dubbo/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[dubbo-go-hessian2] tag v1.11.0 created (now c18594c)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.11.0 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at c18594c (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.11 created (now c18594c)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.11 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at c18594c release note for v1.11.0 No new revisions were added by this update.
[dubbo-go-hessian2] branch master updated: release note for v1.11.0
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new c18594c release note for v1.11.0 c18594c is described below commit c18594c8ecd05dbd953d68ab1fab03d4a1d6c6e5 Author: wangoo AuthorDate: Wed Jan 19 08:41:28 2022 +0800 release note for v1.11.0 --- CHANGE.md | 5 + 1 file changed, 5 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index 84d40bd..7171f69 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,10 @@ # Release Notes +## v1.11.0 + +### New Features +- support encode object to map and vice versa. [#309](https://github.com/apache/dubbo-go-hessian2/pull/309) + ## v1.10.3 ### New Features
[dubbo-go-hessian2] tag v1.10.3 created (now a80067e)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.10.3 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at a80067e (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.10 updated (f989170 -> a80067e)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.10 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. from f989170 release note for v1.10.2 add b015777 fix: decode bool error (#301) add 226f34b use perrors.Errorf to create new error add 9079120 format code add be67b60 Merge pull request #302 from xfstart07/master add 0b16449 add a tool for generate hessian2 java enum define golang code (#304) add 4b69704 reproduce decode interface map bug #299 add ac3b4ed change unit test data for default untype map type add a36dcbf unpack map value to raw value add 1f4cc01 Merge pull request #303 from alpha-baby/issue299 add a80067e release note for v1.10.3 No new revisions were added by this update. Summary of changes: CHANGE.md | 9 ++ README.md | 6 ++ decode_test.go | 15 ++- map.go | 4 +- object.go | 2 +- tools/gen-go-enum/README.md | 94 + tools/gen-go-enum/main.go | 244 7 files changed, 368 insertions(+), 6 deletions(-) create mode 100644 tools/gen-go-enum/README.md create mode 100644 tools/gen-go-enum/main.go
[dubbo-go-hessian2] branch master updated: release note for v1.10.3
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new a80067e release note for v1.10.3 a80067e is described below commit a80067ecec131787bb701ec230339bbaae4fa0ac Author: wangoo AuthorDate: Mon Jan 17 17:10:26 2022 +0800 release note for v1.10.3 --- CHANGE.md | 9 + 1 file changed, 9 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index 0e7ee03..84d40bd 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,14 @@ # Release Notes +## v1.10.3 + +### New Features +- add a tool for generate hessian2 java enum define golang code. [#304](https://github.com/apache/dubbo-go-hessian2/pull/304) + +### Bugfixes +- fix decode interface map bug. [#303](https://github.com/apache/dubbo-go-hessian2/pull/303) +- fix decode bool error. [#302](https://github.com/apache/dubbo-go-hessian2/pull/302) + ## v1.10.2 ### Bugfixes
[dubbo-go-hessian2] branch master updated: add a tool for generate hessian2 java enum define golang code (#304)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 0b16449 add a tool for generate hessian2 java enum define golang code (#304) 0b16449 is described below commit 0b164495efd95d09fe7b18f6de93c607499c45c6 Author: MarsMay AuthorDate: Thu Dec 30 08:42:32 2021 +0800 add a tool for generate hessian2 java enum define golang code (#304) * add a tool for generate hessian2 java enum define golang code --- README.md | 6 ++ tools/gen-go-enum/README.md | 94 + tools/gen-go-enum/main.go | 244 3 files changed, 344 insertions(+) diff --git a/README.md b/README.md index 0f152c2..987027b 100644 --- a/README.md +++ b/README.md @@ -367,3 +367,9 @@ type Dog struct { *Animal } ``` + +## Tools + +### tools/gen-go-enum + +A tool for generate hessian2 java enum define golang code. Read more [details](tools/gen-go-enum/README.md). diff --git a/tools/gen-go-enum/README.md b/tools/gen-go-enum/README.md new file mode 100644 index 000..a13a2c9 --- /dev/null +++ b/tools/gen-go-enum/README.md @@ -0,0 +1,94 @@ +# gen-go-enum + +A tool for generate hessian2 java enum define golang code. + +```sh +go build -o gen-go-enum tools/gen-go-enum/main.go +``` + +For example, run command `gen-go-enum -c com.test.enums.TestColorEnum -v RED -v BLUE -v YELLOW` will create a golang code file like this. + +```go +package enum + +import ( + "strconv" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" +) + +const ( + TestColorEnumRed TestColorEnum = iota + TestColorEnumBlue + TestColorEnumYellow +) + +var _TestColorEnumValues = map[TestColorEnum]string{ + TestColorEnumRed: "RED", + TestColorEnumBlue: "BLUE", + TestColorEnumYellow: "YELLOW", +} + +var _TestColorEnumEntities = map[string]TestColorEnum{ + "RED": TestColorEnumRed, + "BLUE": TestColorEnumBlue, + "YELLOW": TestColorEnumYellow, +} + +type TestColorEnum hessian.JavaEnum + +func (e TestColorEnum) JavaClassName() string { + return "com.test.enums.TestColorEnum" +} + +func (e TestColorEnum) String() string { + if v, ok := _TestColorEnumValues[e]; ok { + return v + } + + return strconv.Itoa(int(e)) +} + +func (e TestColorEnum) EnumValue(s string) hessian.JavaEnum { + if v, ok := _TestColorEnumEntities[s]; ok { + return hessian.JavaEnum(v) + } + + return hessian.InvalidJavaEnum +} + +func NewTestColorEnum(s string) TestColorEnum { + if v, ok := _TestColorEnumEntities[s]; ok { + return v + } + + return TestColorEnum(hessian.InvalidJavaEnum) +} + +func init() { + for v := range _TestColorEnumValues { + hessian.RegisterJavaEnum(v) + } +} +``` + +You can specify more options, like the usage. + +```sh +gen-go-enum can generate golang code for hessian2 java enum. + +Usage: gen-go-enum -c java_classname [-p golang_package_name] [-e golang_enum_name] -v java_enum_value [-v java_enum_value] [-o target_file] + +Options + -c java class name (eg: com.test.enums.TestEnum) + -p golang package name, use 'enum' when not specified (eg: test_enum) + -e golang enum type name, use java class name when not specified (eg: TestEnum) + -v java enum values, can specify multiple (eg: -v TEST1 -v TEST2 -v TEST3) + -o golang code file path, stored in the current directory when not specified + +Example + gen-go-enum -c com.test.enums.TestColorEnum -v RED -v BLUE -v YELLOW + gen-go-enum -c com.test.enums.TestColorEnum -p test_enums -e ColorEnum -v RED -v BLUE -v YELLOW -o ./color_enum.go +``` \ No newline at end of file diff --git a/tools/gen-go-enum/main.go b/tools/gen-go-enum/main.go new file mode 100644 index 000..1082bbe --- /dev/null +++ b/tools/gen-go-enum/main.go @@ -0,0 +1,244 @@ +/* + * 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 + * limit
[dubbo-go-hessian2] tag v1.10.2 created (now f989170)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.10.2 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at f989170 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.10 updated (c715349 -> f989170)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.10 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. from c715349 release note for v1.10.1 add 9b0d390 fix list value not unpacked (#300) add f989170 release note for v1.10.2 No new revisions were added by this update. Summary of changes: CHANGE.md| 5 codec.go | 35 +++--- decode_test.go | 48 hessian_test.go | 4 +-- hessian_test/dup_struct_name_test.go | 4 +-- java_collection.go | 5 +--- list.go | 2 +- 7 files changed, 85 insertions(+), 18 deletions(-)
[dubbo-go-hessian2] branch master updated: release note for v1.10.2
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new f989170 release note for v1.10.2 f989170 is described below commit f989170905c309700aba409389fefcd8f02849b3 Author: wangoo AuthorDate: Fri Dec 24 14:43:03 2021 +0800 release note for v1.10.2 --- CHANGE.md | 5 + 1 file changed, 5 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index 7725c51..0e7ee03 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,10 @@ # Release Notes +## v1.10.2 + +### Bugfixes +- fix list value not unpacked. [#300](https://github.com/apache/dubbo-go-hessian2/pull/300) + ## v1.10.1 ### Bugfixes
[dubbo-go-hessian2] branch master updated: fix list value not unpacked (#300)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 9b0d390 fix list value not unpacked (#300) 9b0d390 is described below commit 9b0d3902284514aa03d4069beefa256e1c870f47 Author: 望哥 AuthorDate: Fri Dec 24 13:56:19 2021 +0800 fix list value not unpacked (#300) fix list value not unpacked --- codec.go | 35 +++--- decode_test.go | 48 hessian_test.go | 4 +-- hessian_test/dup_struct_name_test.go | 4 +-- java_collection.go | 5 +--- list.go | 2 +- 6 files changed, 80 insertions(+), 18 deletions(-) diff --git a/codec.go b/codec.go index 1726438..161bf11 100644 --- a/codec.go +++ b/codec.go @@ -209,15 +209,7 @@ func EnsureInterface(in interface{}, err error) (interface{}, error) { return in, err } - if v, ok := in.(reflect.Value); ok { - in = v.Interface() - } - - if v, ok := in.(*_refHolder); ok { - in = v.value.Interface() - } - - return in, nil + return EnsureRawAny(in), nil } // EnsureRawValue pack the interface with value, and make sure it's not a ref holder @@ -236,6 +228,31 @@ func EnsureRawValue(in interface{}) reflect.Value { return reflect.ValueOf(in) } +// EnsureRawAny unpack if in is a reflect.Value or a ref holder. +func EnsureRawAny(in interface{}) interface{} { + if v, ok := in.(reflect.Value); ok { + if !v.IsValid() { + return nil + } + + in = v.Interface() + } + + if v, ok := in.(*_refHolder); ok { + in = v.value + } + + if v, ok := in.(reflect.Value); ok { + if !v.IsValid() { + return nil + } + + in = v.Interface() + } + + return in +} + // SetValue set the value to dest. // It will auto check the Ptr pack level and unpack/pack to the right level. // It make sure success to set value diff --git a/decode_test.go b/decode_test.go index 0e57f45..9bf0efe 100644 --- a/decode_test.go +++ b/decode_test.go @@ -190,3 +190,51 @@ func TestIssue214(t *testing.T) { t.Log(decode) assert.True(t, reflect.DeepEqual(c, decode)) } + +type Issue299Args1 struct { + Label string + Key string +} + +func (Issue299Args1) JavaClassName() string { + return "com.test.Issue299Args1" +} + +type Issue299MockData struct { + Args []interface{} +} + +func (Issue299MockData) JavaClassName() string { + return "com.test.Issue299MockData" +} + +func TestIssue299HessianDecode(t *testing.T) { + RegisterPOJO(new(Issue299Args1)) + RegisterPOJO(new(Issue299MockData)) + + d := { + Args: []interface{}{ + []*Issue299Args1{ + {Label: "1", Key: "2"}, + }, + }, + } + + encoder := NewEncoder() + err := encoder.Encode(d) + if err != nil { + t.Errorf("encode obj error: %v", err) + return + } + decoder := NewDecoder(encoder.Buffer()) + doInterface, err := decoder.Decode() + if err != nil { + t.Errorf("decode obj error: %v", err) + return + } + do := doInterface.(*Issue299MockData) + if !reflect.DeepEqual(d, do) { + t.Errorf("not equal d: %+v, do: %+v", d, do) + return + } +} diff --git a/hessian_test.go b/hessian_test.go index 9ee1469..a65c61f 100644 --- a/hessian_test.go +++ b/hessian_test.go @@ -106,8 +106,8 @@ func doTestResponse(t *testing.T, packageType PackageType, responseStatus byte, return } - in, _ := EnsureInterface(UnpackPtrValue(EnsurePackValue(body)), nil) - out, _ := EnsureInterface(UnpackPtrValue(EnsurePackValue(decodedResponse.RspObj)), nil) + in := EnsureRawAny(UnpackPtrValue(EnsurePackValue(body))) + out := EnsureRawAny(UnpackPtrValue(EnsurePackValue(decodedResponse.RspObj))) assert.Equal(t, in, out) } diff --git a/hessian_test/dup_struct_name_test.go b/hessian_test/dup_struct_name_test.go index 0c34d44..14a0666 100644 --- a/hessian_test/dup_struct_name_test.go +++ b/hessian_test/dup_struct_name_test.go @@ -177,8 +177,8 @@ func checkResponseBody(t *testing.T, decodedResponse *hessian.Response, h *hessi return } - in, _ := hessian.EnsureInterface(hessian.UnpackPtrValue(hessian.EnsurePackValue(body)), nil) - out, _ := hessian.EnsureInterface
[dubbo-go-hessian2] tag v1.10.1 created (now c715349)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.10.1 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at c715349 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.10 updated (49f9da8 -> c715349)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.10 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. from 49f9da8 release note for v1.10.0 add df62010 support java integer null add 75ff950 Merge pull request #296 from sanxun0325/java_interger_null add d26d6da fix parse basic type bug add 7f38305 Merge pull request #298 from luky116/fix-parseIntBug2 add c715349 release note for v1.10.1 No new revisions were added by this update. Summary of changes: CHANGE.md | 6 ++ codec.go | 66 -- int.go | 3 + int_test.go| 1 + object_test.go | 19 +++ .../src/main/java/test/TestCustomReply.java| 20 +++ test_hessian/src/main/java/test/model/User.java| 18 ++ 7 files changed, 78 insertions(+), 55 deletions(-)
[dubbo-go-hessian2] branch master updated: release note for v1.10.1
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new c715349 release note for v1.10.1 c715349 is described below commit c715349dbc205aacf0dc3bd791e8e08b6d08cb4e Author: wangoo AuthorDate: Tue Dec 21 11:05:24 2021 +0800 release note for v1.10.1 --- CHANGE.md | 6 ++ 1 file changed, 6 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index d270416..7725c51 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,11 @@ # Release Notes +## v1.10.1 + +### Bugfixes +- support java integer null. [#296](https://github.com/apache/dubbo-go-hessian2/pull/296) +- fix parse basic type bug. [#298](https://github.com/apache/dubbo-go-hessian2/pull/298) + ## v1.10.0 ### New Features
[dubbo-go-hessian2] tag v1.10.0 created (now 49f9da8)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.10.0 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at 49f9da8 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.10 created (now 49f9da8)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.10 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at 49f9da8 release note for v1.10.0 No new revisions were added by this update.
[dubbo-go-hessian2] branch master updated: release note for v1.10.0
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 49f9da8 release note for v1.10.0 49f9da8 is described below commit 49f9da849c1b5794a6ed554a00b31d967c79bd41 Author: wangoo AuthorDate: Sat Dec 4 00:08:42 2021 +0800 release note for v1.10.0 --- CHANGE.md | 5 + 1 file changed, 5 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index cd695d6..d270416 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,10 @@ # Release Notes +## v1.10.0 + +### New Features +- support java function param type. [#295](https://github.com/apache/dubbo-go-hessian2/pull/295) + ## v1.9.5 ### New Features
[dubbo-go-hessian2] branch master updated: support java function param type (#295)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 2fd463b support java function param type (#295) 2fd463b is described below commit 2fd463b75f652e34d2fbd3748e6408cd1e7f5664 Author: binbin.zhang AuthorDate: Fri Dec 3 18:08:59 2021 +0800 support java function param type (#295) * support java function param type * update readme.md Co-authored-by: sanxun0325 --- README.md | 69 ++- param.go | 28 ++ 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2cb4f5b..0f152c2 100644 --- a/README.md +++ b/README.md @@ -195,8 +195,74 @@ type MyUser struct { ``` + Encoding param name -# hessian.SetTagIdentifier +When a Java method declares an argument as a parent class, it actually hope receives a subclass, +You can specify the encoding type of the parameter separately. + +# java-server + +```java +public abstract class User { +} + +public class MyUser extends User implements Serializable { + +private String userFullName; + +private String familyPhoneNumber; +} + +public interface UserProvider { +String GetUser(User user); +} + +public class UserProviderImpl implements UserProvider { +public UserProviderImpl() { +} + +public String GetUser(User user) { +MyUser myUser=(MyUser)user; +return myUser.getUserFullName(); +} +} + +``` + +# go-client + +```go +type MyUser struct { +UserFullName string `hessian:"userFullName"` +FamilyPhoneNumber string // default convert to => familyPhoneNumber +} + +func (m *MyUser) JavaClassName() string { +return "com.company.MyUser" +} + +func (m *MyUser) JavaParamName() string { +return "com.company.User" +} + +type UserProvider struct { +GetUser func(ctx context.Context, user *MyUser) (string, error) `dubbo:"GetUser"` +} +``` + + + + Set method Alias + +When the Go client calls the Java server, the first letter of the method is converted to lowercase by default,you can use the dubbo tag to set method alias. + +```go +type UserProvider struct { +GetUser func(ctx context.Context) (*User, error) `dubbo:"GetUser"` +} +``` + + hessian.SetTagIdentifier You can use `hessian.SetTagIdentifier` to customize tag-identifier of hessian, which takes effect to both encoder and decoder. @@ -237,6 +303,7 @@ The encoded bytes of the struct `MyUser` is as following: ``` Using Java collections + By default, the output of Hessian Java impl of a Java collection like java.util.HashSet will be decoded as `[]interface{}` in `go-hessian2`. To apply the one-to-one mapping relationship between certain Java collection class and your Go struct, examples are as follows: diff --git a/param.go b/param.go new file mode 100644 index 000..f30f761 --- /dev/null +++ b/param.go @@ -0,0 +1,28 @@ +/* + * 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 + +// Param interface +// !!! Pls attention that Every field name should be upper case. +// specifies the Java method parameter type. +// if this interface is not implemented, the pojo javaClassName is +// used as the method parameter type by default +type Param interface { + POJO + JavaParamName() string +}
[dubbo-go-pixiu] branch develop updated: upgrade hessian to v1.9.5 (#301)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/dubbo-go-pixiu.git The following commit(s) were added to refs/heads/develop by this push: new ec68432 upgrade hessian to v1.9.5 (#301) ec68432 is described below commit ec68432b71b733a1d87b7a182ded2004fed073d9 Author: 望哥 AuthorDate: Fri Nov 19 11:29:49 2021 +0800 upgrade hessian to v1.9.5 (#301) --- go.mod | 4 ++-- go.sum | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 07bc3d2..ac6ab2c 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.14 require ( github.com/alibaba/sentinel-golang v1.0.2 github.com/apache/dubbo-go v1.5.7 - github.com/apache/dubbo-go-hessian2 v1.9.4 + github.com/apache/dubbo-go-hessian2 v1.9.5 github.com/creasty/defaults v1.5.2 github.com/dubbogo/dubbo-go-pixiu-filter v0.1.4 github.com/dubbogo/go-zookeeper v1.0.3 @@ -20,8 +20,8 @@ require ( github.com/google/uuid v1.2.0 // indirect github.com/jhump/protoreflect v1.9.0 github.com/mitchellh/mapstructure v1.4.1 - github.com/opentrx/seata-golang/v2 v2.0.5 github.com/nacos-group/nacos-sdk-go v1.0.8 + github.com/opentrx/seata-golang/v2 v2.0.5 github.com/pkg/errors v0.9.1 github.com/prometheus/common v0.29.0 // indirect github.com/shirou/gopsutil v3.21.3+incompatible // indirect diff --git a/go.sum b/go.sum index 02570a2..6641c42 100644 --- a/go.sum +++ b/go.sum @@ -93,8 +93,8 @@ github.com/apache/dubbo-getty v1.4.5/go.mod h1:mcDyiu7M/TVrYDyL8TxDemQkOdvEqqHSQ github.com/apache/dubbo-go v1.5.7 h1:aEdQyUH3duDYMw8wBYziuDBUwNBSVyYlUqqAQJ2ikZA= github.com/apache/dubbo-go v1.5.7/go.mod h1:KHmSHx2/foxW0dVlQIrqQ4Vs1Clg3d4UIkwKkuhaZt8= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/dubbo-go-hessian2 v1.9.4 h1:dj8yT7Jjq7q6skix7Tn/oH/IRmw9dQBQvATnpUDuaHg= -github.com/apache/dubbo-go-hessian2 v1.9.4/go.mod h1:7rEw9guWABQa6Aqb8HeZcsYPHsOS7XT1qtJvkmI6c5w= +github.com/apache/dubbo-go-hessian2 v1.9.5 h1:2bsVZpoDrlQtmNlddWxIKvnkjjrEg/9eIsXEzR2YFqY= +github.com/apache/dubbo-go-hessian2 v1.9.5/go.mod h1:7rEw9guWABQa6Aqb8HeZcsYPHsOS7XT1qtJvkmI6c5w= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= @@ -191,7 +191,6 @@ github.com/dubbogo/dubbo-go-pixiu-filter v0.1.4/go.mod h1:d6SDK5BHl/QCvg84BN+g6L github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl83me8g= github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= -github.com/dubbogo/gost v1.10.1/go.mod h1:+mQGS51XQEUWZP2JeGZTxJwipjRKtJO7Tr+FOg+72rI= github.com/dubbogo/gost v1.11.11/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/gost v1.11.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/gost v1.11.14 h1:9lfcdILOmqTOVAW1fPHa5uf1NrD6jlIOBe4vf8576yQ=
[dubbo-go-hessian2] tag v1.9.5 created (now 7cabe51)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.9.5 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at 7cabe51 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.9 updated (23c41ad -> 7cabe51)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.9 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. from 23c41ad release note for v1.9.4 add 3a4ef0b support serialize UUID to string (#285) add ad93624 update load pojo repository (#287) add 57240d6 convert pointer to encode (#289) add 9653a02 fix error check (#288) add 5d3d18b fix go type name for list (#290) add 7cabe51 release note for v1.9.5 No new revisions were added by this update. Summary of changes: CHANGE.md| 11 Makefile | 4 +-- codec.go | 7 + codec_test.go| 13 ++ date_test.go | 9 +-- decode.go| 6 ++--- encode.go| 6 - encode_test.go | 50 hessian_test/dup_struct_name_test.go | 5 java_sql_time.go | 4 +-- java_unknown_exception_test.go | 2 +- java_util.go | 3 +-- java_util/uuid.go| 42 ++ java_util_test.go| 2 +- list.go | 10 map.go | 2 +- object.go| 9 +++ pojo.go | 45 +--- pojo_test.go | 46 + serialize.go | 4 +-- test_hessian/pom.xml | 2 +- 21 files changed, 194 insertions(+), 88 deletions(-) create mode 100644 pojo_test.go
[dubbo-go-hessian2] branch master updated: release note for v1.9.5
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 7cabe51 release note for v1.9.5 7cabe51 is described below commit 7cabe51f90162d12ad0e3095c60fedf1d170053b Author: wangoo AuthorDate: Thu Nov 18 17:02:12 2021 +0800 release note for v1.9.5 --- CHANGE.md | 11 +++ 1 file changed, 11 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index e365161..cd695d6 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,16 @@ # Release Notes +## v1.9.5 + +### New Features +- support serialize UUID to string. [#285](https://github.com/apache/dubbo-go-hessian2/pull/285) +- support encode non-pointer instance for pointer POJO definition. [#289](https://github.com/apache/dubbo-go-hessian2/pull/289) + +### Bugfixes +- fix POJO registration. [#287](https://github.com/apache/dubbo-go-hessian2/pull/287) +- fix EOF error check. [#288](https://github.com/apache/dubbo-go-hessian2/pull/288) +- fix go type name for list. [#290](https://github.com/apache/dubbo-go-hessian2/pull/290) + ## v1.9.4 ### New Features
[dubbo-go-hessian2] branch master updated: fix error check (#288)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 9653a02 fix error check (#288) 9653a02 is described below commit 9653a02986fcf3c6f20d2aff634475ad7bfa35e5 Author: 望哥 AuthorDate: Tue Nov 16 18:42:16 2021 +0800 fix error check (#288) --- date_test.go | 9 +++-- decode.go| 6 +++--- java_sql_time.go | 2 +- list.go | 4 ++-- map.go | 2 +- object.go| 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/date_test.go b/date_test.go index 7e1d36a..f0a8b6f 100644 --- a/date_test.go +++ b/date_test.go @@ -105,6 +105,7 @@ func TestEncDateNull(t *testing.T) { e *Encoder d *Decoder res interface{} + err error ) v = "2014-02-09 06:15:23 +0800 CST" tz, _ = time.Parse("2006-01-02 15:04:05 +0800 CST", v) @@ -122,12 +123,16 @@ func TestEncDateNull(t *testing.T) { Date3: d3, } e = NewEncoder() - e.Encode(date) + err = e.Encode(date) + if err != nil { + t.Fatal(err) + } if len(e.Buffer()) == 0 { t.Fail() } d = NewDecoder(e.Buffer()) - res, _ = d.Decode() + res, err = d.Decode() + assert.Nil(t, err) assert.Equal(t, ZeroDate, res.(*DateDemo).Date) assert.Equal(t, 2, len(res.(*DateDemo).Dates)) assert.Equal(t, tz.Local().String(), (*res.(*DateDemo).Dates[0]).String()) diff --git a/decode.go b/decode.go index 00b8461..89af853 100644 --- a/decode.go +++ b/decode.go @@ -49,12 +49,12 @@ func NewDecoder(b []byte) *Decoder { return {reader: bufio.NewReader(bytes.NewReader(b)), typeRefs: {records: map[string]bool{}}} } -// NewDecoder generate a decoder instance +// NewDecoderSize generate a decoder instance. func NewDecoderSize(b []byte, size int) *Decoder { return {reader: bufio.NewReaderSize(bytes.NewReader(b), size), typeRefs: {records: map[string]bool{}}} } -// NewDecoder generate a decoder instance with skip +// NewDecoderWithSkip generate a decoder instance with skip. func NewDecoderWithSkip(b []byte) *Decoder { return {reader: bufio.NewReader(bytes.NewReader(b)), typeRefs: {records: map[string]bool{}}, isSkip: true} } @@ -224,7 +224,7 @@ func (d *Decoder) DecodeValue() (interface{}, error) { ) tag, err = d.ReadByte() - if err == io.EOF { + if perrors.Is(err, io.EOF) { return nil, err } diff --git a/java_sql_time.go b/java_sql_time.go index 18c2a49..8edee13 100644 --- a/java_sql_time.go +++ b/java_sql_time.go @@ -124,7 +124,7 @@ func (JavaSqlTimeSerializer) DecObject(d *Decoder, typ reflect.Type, cls *classI d.appendRefs(vRef.Interface()) tag, err := d.ReadByte() - if err == io.EOF { + if perrors.Is(err, io.EOF) { return nil, err } date, err := d.decDate(int32(tag)) diff --git a/list.go b/list.go index b93f22e..94603c8 100644 --- a/list.go +++ b/list.go @@ -359,7 +359,7 @@ func (d *Decoder) readTypedListValue(length int, listTyp string, isVariableArr b for j := 0; j < length || isVariableArr; j++ { it, err := d.DecodeValue() if err != nil { - if err == io.EOF && isVariableArr { + if perrors.Is(err, io.EOF) && isVariableArr { break } return nil, perrors.WithStack(err) @@ -414,7 +414,7 @@ func (d *Decoder) readUntypedList(tag byte) (interface{}, error) { for j := 0; j < length || isVariableArr; j++ { it, err := d.DecodeValue() if err != nil { - if err == io.EOF && isVariableArr { + if perrors.Is(err, io.EOF) && isVariableArr { break } return nil, perrors.WithStack(err) diff --git a/map.go b/map.go index cd340df..034ccb1 100644 --- a/map.go +++ b/map.go @@ -192,7 +192,7 @@ func (d *Decoder) decMapByValue(value reflect.Value) error { entryKey, err = d.DecodeValue() if err != nil { // EOF means the end flag 'Z' of map is already read - if err == io.EOF { + if perrors.Is(err, io.EOF) { break } else { return perrors.WithStack(err) diff --git a/object.go b/object.go index 84ee94e..45a7eb2 100644 --- a/object.go +++ b/object.go @@ -499,7 +499,7 @@ func (d *Decoder) decInstance(typ reflect.Ty
[dubbo-go-hessian2] branch master updated: convert pointer to encode (#289)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 57240d6 convert pointer to encode (#289) 57240d6 is described below commit 57240d6215bbf487b30cab2f6aa0bf351dc590c9 Author: binbin.zhang AuthorDate: Tue Nov 16 14:37:06 2021 +0800 convert pointer to encode (#289) Co-authored-by: sanxun0325 --- codec.go | 7 +++ codec_test.go | 13 + encode.go | 6 +- encode_test.go | 50 ++ serialize.go | 4 ++-- 5 files changed, 77 insertions(+), 3 deletions(-) diff --git a/codec.go b/codec.go index 5087efa..425468c 100644 --- a/codec.go +++ b/codec.go @@ -476,3 +476,10 @@ func ConvertSliceValueType(destTyp reflect.Type, v reflect.Value) (reflect.Value return sl, nil } + +//PackPtrInterface pack struct interface to pointer interface +func PackPtrInterface(s interface{}, value reflect.Value) interface{} { + vv := reflect.New(reflect.TypeOf(s)) + vv.Elem().Set(value) + return vv.Interface() +} diff --git a/codec_test.go b/codec_test.go index a4cdd1b..b2dd937 100644 --- a/codec_test.go +++ b/codec_test.go @@ -18,9 +18,14 @@ package hessian import ( + "reflect" "testing" ) +import ( + "github.com/stretchr/testify/assert" +) + // go test -v -run TestPackUint16 func TestPackUint16(t *testing.T) { // var arr []byte @@ -57,3 +62,11 @@ func TestPackInt64(t *testing.T) { t.Fatalf("v:0X%d, pack-unpack value:0X%x\n", v, r) } } + +func TestPackPtrInterface(t *testing.T) { + v := "struct" + vv := reflect.ValueOf(v) + sPointer, ok := PackPtrInterface(v, vv).(*string) + assert.True(t, ok) + assert.True(t, *sPointer == "struct") +} diff --git a/encode.go b/encode.go index c26832e..0daf3e0 100644 --- a/encode.go +++ b/encode.go @@ -160,7 +160,11 @@ func (e *Encoder) Encode(v interface{}) error { switch t.Kind() { case reflect.Struct: vv := reflect.ValueOf(v) - vv = UnpackPtr(vv) + if vv.Kind() != reflect.Ptr { + v = PackPtrInterface(v, vv) + } else { + vv = UnpackPtr(vv) + } if !vv.IsValid() { e.buffer = EncNull(e.buffer) return nil diff --git a/encode_test.go b/encode_test.go index 543452f..6db3a98 100644 --- a/encode_test.go +++ b/encode_test.go @@ -87,3 +87,53 @@ func testSimpleEncode(t *testing.T, v interface{}) { err := e.Encode(v) assert.Nil(t, err) } + +type BenchData struct { + name string +} + +func (b *BenchData) JavaClassName() string { + return "test.bench.BenchData" +} + +// Benchmark_Struct_Encode 2231869 506.8 ns/op 560 B/op 7 allocs/op +func Benchmark_Struct_Encode(b *testing.B) { + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + NewEncoder().Encode(BenchData{}) + } +} + +// Benchmark_Pointer_Encode 2565778 476.1 ns/op 560 B/op 7 allocs/op +func Benchmark_Pointer_Encode(b *testing.B) { + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + NewEncoder().Encode({}) + } +} + +// Benchmark_Struct_Encode_82307214 519.4 ns/op 560 B/op 7 allocs/op +func Benchmark_Struct_Encode_8(b *testing.B) { + b.ReportAllocs() + b.ResetTimer() + b.SetParallelism(8) + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + NewEncoder().Encode(BenchData{}) + } + }) +} + +// Benchmark_Pointer_Encode_8 2460842 476.7 ns/op 560 B/op 7 allocs/op +func Benchmark_Pointer_Encode_8(b *testing.B) { + b.ReportAllocs() + b.ResetTimer() + b.SetParallelism(8) + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + NewEncoder().Encode({}) + } + }) +} diff --git a/serialize.go b/serialize.go index b57702b..ca738ea 100644 --- a/serialize.go +++ b/serialize.go @@ -69,7 +69,7 @@ func (IntegerSerializer) DecObject(d *Decoder, typ reflect.Type, cls *classInfo) } func (IntegerSerializer) EncObject(e *Encoder, v POJO) error { - bigInt, ok := v.(bigInteger) + bigInt, ok := v.(*bigInteger) if !ok { return e.encObject(v) } @@ -80,7 +80,7 @@ func (IntegerSerializer) En
[dubbo-go-hessian2] tag v1.9.4 created (now 23c41ad)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.9.4 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at 23c41ad (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch 1.9 updated (e0c085c -> 23c41ad)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.9 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. from e0c085c release note for v1.9.3 add 4d74555 feat(*): add Integer[] serializer add bc7edd2 feat(*): support wrapper classes for Java basic types add 8512ed3 style(*): add nolint add b470210 feat(*): support java Character[] & format unit test add feebbd1 feat(*): use uint8 as Byte & use int16 as Short add 9aafe3b feat(*): add cross language encode/decode test add 74a8ece Merge pull request #278 from Mulavar/feat/wrap-clazz add 89d84be go struct name 加入PkgPath信息,用于区分同名的struct add b8119a5 兼容多种结构 add d12e050 go.mod回滚 add 98f6ead 优化代码 add 1a59e82 Add Unit Tests add 8f630f5 优化单元测试 add b701ba1 新增异构测试 add 1923caa 优化代码 add 6e75380 调整单元测试结构 add 3bc5076 优化代码 add 0ded318 优化代码 add 1ff1331 移除go版本号 add e03a801 更新单元测试版本 add 8959733 移除go版本号 add a0c5132 Merge pull request #279 from Chans-Open-Source/feature/optimizing_the_registration_goname add 6d2d578 修正单元测试依赖module名 add ca60bfe 迁移单元测试内容 add 9e6bd1c optimize package structure for unit test add ce53048 Merge pull request #1 from wongoo/feature/modify_unit_test_module_name add bf96d95 modify unit test package name add b4471a9 upgrade yaml add 80c9106 调整文件结构 add efc213a remove go version add cd57270 rename dir name add 1ec5c50 Merge pull request #281 from Chans-Open-Source/feature/modify_unit_test_module_name add 3fa24f7 fixed: #282 add 9721399 fixed: #282 add 3b3cf21 优化匹配正则 add 1478cb7 忽略0值处理 add cbad558 简化正则 add 5bdf65a 优化正则 add 53cd523 优化为switch方式 add 0214778 优化为switch方式 add 9c70e1f 优化为switch方式 add b9d8878 拆分为2个switch add 112adfe 调整为1个switch add 041146a 添加更多指针型单元测试 add 43d1925 调整导包位置 add ea64fc7 Merge pull request #283 from chans-open-source/feature/fix_encode_type add 23c41ad release note for v1.9.4 No new revisions were added by this update. Summary of changes: CHANGE.md | 9 + array.go | 257 + array_test.go | 148 double_test.go | 9 + encode.go | 10 + encode_test.go | 10 + go.mod | 1 - go.sum | 1 - hessian_test/dup_struct_name_test.go | 183 +++ .../hessian_test/dupclass.go | 10 +- int_test.go| 27 +++ list.go| 3 +- object_test.go | 50 output/output.go | 8 + output/testfuncs/wrapper_class_array.go| 86 +++ pojo.go| 29 ++- string_test.go | 5 + ...JavaSqlTime.java => TestWrapperClassArray.java} | 32 ++- .../test/java/unit/GoWrapperClassArrayTest.java| 44 19 files changed, 901 insertions(+), 21 deletions(-) create mode 100644 array.go create mode 100644 array_test.go create mode 100644 hessian_test/dup_struct_name_test.go copy test_hessian/src/main/java/test/tuple/TupleProvider.java => hessian_test/hessian_test/dupclass.go (86%) create mode 100644 output/testfuncs/wrapper_class_array.go copy test_hessian/src/main/java/test/{TestJavaSqlTime.java => TestWrapperClassArray.java} (51%) create mode 100644 test_hessian/src/test/java/unit/GoWrapperClassArrayTest.java
[dubbo-go-hessian2] branch master updated: release note for v1.9.4
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 23c41ad release note for v1.9.4 23c41ad is described below commit 23c41ad4aa1e1b7ea1813cae4ca041dfea066f11 Author: wangoo AuthorDate: Tue Oct 19 17:50:16 2021 +0800 release note for v1.9.4 --- CHANGE.md | 9 + 1 file changed, 9 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index 2e642a3..e365161 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,14 @@ # Release Notes +## v1.9.4 + +### New Features +- support wrapper classes for Java basic types. [#278](https://github.com/apache/dubbo-go-hessian2/pull/278) + +### Bugfixes +- fix registration ignored for struct with same name in diff package. [#279](https://github.com/apache/dubbo-go-hessian2/pull/279) +- fix cannot encode pointer of raw type. [#283](https://github.com/apache/dubbo-go-hessian2/pull/283) + ## v1.9.3 ### New Features
[dubbo-go-hessian2] tag v1.9.3 created (now e0c085c)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.9.3 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at e0c085c (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch master updated (20ce834 -> e0c085c)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. from 20ce834 Merge pull request #276 from Chans-Open-Source/fix/fix_get_argument_java_type add e0c085c release note for v1.9.3 No new revisions were added by this update. Summary of changes: CHANGE.md | 10 ++ 1 file changed, 10 insertions(+)
[dubbo-go-pixiu] branch develop updated: doc: fix wrong dir path in start.sh (#218)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/dubbo-go-pixiu.git The following commit(s) were added to refs/heads/develop by this push: new 150fd36 doc: fix wrong dir path in start.sh (#218) 150fd36 is described below commit 150fd36001e01ebe11fc63789ee97ddc7ac4ec57 Author: MasterKenway <40176260+masterken...@users.noreply.github.com> AuthorDate: Mon Jul 19 19:07:11 2021 +0800 doc: fix wrong dir path in start.sh (#218) Co-authored-by: Xin.Zh --- samples/dubbogo/simple/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/dubbogo/simple/start.sh b/samples/dubbogo/simple/start.sh index 2bafa5b..b775c24 100755 --- a/samples/dubbogo/simple/start.sh +++ b/samples/dubbogo/simple/start.sh @@ -22,4 +22,4 @@ DIR=$(cd $(dirname $0) && pwd ) echo $DIR -./pixiu -c ${DIR}/$1/conf.yaml -a ${DIR}/$1/api_config.yaml \ No newline at end of file +./pixiu -c ${DIR}/$1/pixiu/conf.yaml -a ${DIR}/$1/pixiu/api_config.yaml \ No newline at end of file
[dubbo-getty] branch improve/delte-handleLoop updated (b1e566c -> 389e30d)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch improve/delte-handleLoop in repository https://gitbox.apache.org/repos/asf/dubbo-getty.git. from b1e566c Merge branch 'master' into improve/delte-handleLoop add 389e30d increase grNum before starting goroutine No new revisions were added by this update. Summary of changes: session.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
[dubbo-go-hessian2] branch master updated: reuse allocated buffer (#271)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new dad2892 reuse allocated buffer (#271) dad2892 is described below commit dad28924458a39d4b56e803f14e130b0156cae39 Author: tyltr <31768692+tylitian...@users.noreply.github.com> AuthorDate: Tue Jul 6 08:43:17 2021 +0800 reuse allocated buffer (#271) * reuse buffer avoid allocate * reuse buffer clean * typo * reuse buf size 512 --- encode.go | 18 -- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/encode.go b/encode.go index b6d9aed..cd3e11a 100644 --- a/encode.go +++ b/encode.go @@ -21,9 +21,7 @@ import ( "reflect" "time" "unsafe" -) -import ( perrors "github.com/pkg/errors" ) @@ -56,6 +54,22 @@ func (e *Encoder) Clean() { e.refMap = make(map[unsafe.Pointer]_refElem, 7) } +// ReuseBufferClean reuse the Encoder for a new object encoding. +// it reuse allocated buffer and reduce memory-allocation. +func (e *Encoder) ReuseBufferClean() { + var buffer []byte + if cap(e.buffer) <= 512 { + // reuse buffer, avoid allocate + buffer = e.buffer[:0] + } else { + // avoiding memory leak caused by growth of underlying array + buffer = make([]byte, 64) + } + e.classInfoList = nil + e.buffer = buffer[:0] + e.refMap = make(map[unsafe.Pointer]_refElem, 7) +} + // Buffer returns byte buffer func (e *Encoder) Buffer() []byte { return e.buffer[:]
[dubbo-go-hessian2] branch master updated: fix getting nil result for decoding list to generic interface field (#269)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new e714430 fix getting nil result for decoding list to generic interface field (#269) e714430 is described below commit e7144303cf1a338c905e31a574e57bf3effee6a5 Author: 望哥 AuthorDate: Mon Jul 5 09:59:57 2021 +0800 fix getting nil result for decoding list to generic interface field (#269) --- codec.go | 23 -- object.go | 8 +++-- object_test.go | 35 ++ test_hessian/pom.xml | 8 ++--- .../src/main/java/test/TestCustomReply.java| 20 - 5 files changed, 78 insertions(+), 16 deletions(-) diff --git a/codec.go b/codec.go index 2df9e58..5087efa 100644 --- a/codec.go +++ b/codec.go @@ -397,14 +397,7 @@ func SetSlice(dest reflect.Value, objects interface{}) error { } if ref, ok := objects.(*_refHolder); ok { - v, err := ConvertSliceValueType(destTyp, ref.value) - if err != nil { - return err - } - SetValue(dest, v) - ref.change(v) // change finally - ref.notify() // delay set value to all destinations - return nil + return unpackRefHolder(dest, destTyp, ref) } v := EnsurePackValue(objects) @@ -422,9 +415,21 @@ func SetSlice(dest reflect.Value, objects interface{}) error { return nil } +// unpackRefHolder unpack the ref holder when decoding slice finished. +func unpackRefHolder(dest reflect.Value, destTyp reflect.Type, ref *_refHolder) error { + v, err := ConvertSliceValueType(destTyp, ref.value) + if err != nil { + return err + } + SetValue(dest, v) + ref.change(v) // change finally + ref.notify() // delay set value to all destinations + return nil +} + // ConvertSliceValueType convert to slice of destination type func ConvertSliceValueType(destTyp reflect.Type, v reflect.Value) (reflect.Value, error) { - if destTyp == v.Type() { + if destTyp == v.Type() || destTyp.Kind() == reflect.Interface { return v, nil } diff --git a/object.go b/object.go index 0172162..0186992 100644 --- a/object.go +++ b/object.go @@ -539,8 +539,12 @@ func (d *Decoder) decInstance(typ reflect.Type, cls *classInfo) (interface{}, er return nil, perrors.WithStack(err) } if s != nil { - // set value which accepting pointers - SetValue(fldRawValue, EnsurePackValue(s)) + if ref, ok := s.(*_refHolder); ok { + _ = unpackRefHolder(fldRawValue, fldTyp, ref) + } else { + // set value which accepting pointers + SetValue(fldRawValue, EnsurePackValue(s)) + } } default: return nil, perrors.Errorf("unknown struct member type: %v %v", kind, typ.Name()+"."+fieldStruct.Name) diff --git a/object_test.go b/object_test.go index ebc5b5d..e5b51f1 100644 --- a/object_test.go +++ b/object_test.go @@ -812,3 +812,38 @@ func TestCustomReplyGenericResponseBusinessData(t *testing.T) { testDecodeFramework(t, "customReplyGenericResponseBusinessData", res) } + +func TestCustomReplyGenericResponseList(t *testing.T) { + data := []*BusinessData{ + { + Name: "apple", + Count: 5, + }, + { + Name: "banana", + Count: 6, + }, + } + res := { + Code: 202, + Data: data, + } + RegisterPOJO(data[0]) + RegisterPOJO(res) + + testDecodeFrameworkFunc(t, "customReplyGenericResponseList", func(r interface{}) { + expect, ok := r.(*GenericResponse) + if !ok { + t.Errorf("expect *GenericResponse, but get %v", r) + return + } + list, dataOk := expect.Data.([]interface{}) + if !dataOk { + t.Errorf("expect []interface{}, but get %v", expect.Data) + return + } + assert.Equal(t, res.Code, expect.Code) + assert.True(t, reflect.DeepEqual(dat
[dubbo-go-hessian2] branch master updated: fix #266 upgrade dubbo version
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 8dc4b20 fix #266 upgrade dubbo version 8dc4b20 is described below commit 8dc4b20052ff12ff316475683da3d28ed723ba73 Author: wangoo AuthorDate: Sat May 22 16:05:14 2021 +0800 fix #266 upgrade dubbo version --- test_dubbo/pom.xml | 4 ++-- test_hessian/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test_dubbo/pom.xml b/test_dubbo/pom.xml index f8df68e..ba300b7 100644 --- a/test_dubbo/pom.xml +++ b/test_dubbo/pom.xml @@ -31,7 +31,7 @@ org.apache.dubbo dubbo -2.7.1 + 2.7.11 compile @@ -70,4 +70,4 @@ - \ No newline at end of file + diff --git a/test_hessian/pom.xml b/test_hessian/pom.xml index 868d54e..436a8d0 100644 --- a/test_hessian/pom.xml +++ b/test_hessian/pom.xml @@ -43,9 +43,9 @@ compile -com.alibaba +org.apache.dubbo dubbo -2.6.5 +2.7.11 com.alibaba
[dubbo-go-hessian2] branch master updated: upgrade jetty dependency
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 59acf74 upgrade jetty dependency 59acf74 is described below commit 59acf74088f2ff04aa3e400590cd4a63c305413f Author: wangoo AuthorDate: Fri May 21 21:59:57 2021 +0800 upgrade jetty dependency --- test_hessian/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_hessian/pom.xml b/test_hessian/pom.xml index a4db3f1..868d54e 100644 --- a/test_hessian/pom.xml +++ b/test_hessian/pom.xml @@ -39,7 +39,7 @@ org.eclipse.jetty jetty-servlet -9.4.16.v20190411 +9.4.41.v20210516 compile @@ -102,4 +102,4 @@ - \ No newline at end of file +
[dubbo-go-hessian2] branch master updated: go to java list and array (#265)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git The following commit(s) were added to refs/heads/master by this push: new 6f053c6 go to java list and array (#265) 6f053c6 is described below commit 6f053c6c6b3a572f3388f22e0056c5e7b412f1c0 Author: 望哥 AuthorDate: Thu May 6 10:58:53 2021 +0800 go to java list and array (#265) --- output/output.go | 2 + output/testfuncs/list.go | 38 ++ output/testfuncs/user.go | 33 test_hessian/src/main/java/test/model/User.java| 46 ++ .../src/test/java/unit/GoUserListTest.java | 40 +++ 5 files changed, 159 insertions(+) diff --git a/output/output.go b/output/output.go index 65082ca..f619a1a 100644 --- a/output/output.go +++ b/output/output.go @@ -40,6 +40,8 @@ func init() { funcMap["Java8TimeYear"] = testfuncs.Java8TimeYear funcMap["Java8LocalDate"] = testfuncs.Java8LocalDate funcMap["JavaException"] = testfuncs.JavaException + funcMap["UserArray"] = testfuncs.UserArray + funcMap["UserList"] = testfuncs.UserList } func main() { diff --git a/output/testfuncs/list.go b/output/testfuncs/list.go new file mode 100644 index 000..c9084f3 --- /dev/null +++ b/output/testfuncs/list.go @@ -0,0 +1,38 @@ +/* + * 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 testfuncs + +import ( + hessian "github.com/apache/dubbo-go-hessian2" +) + +func UserArray() []byte { + e := hessian.NewEncoder() + _ = e.Encode([]*User{ + {"wongoo"}, {"alex"}, + }) + return e.Buffer() +} + +func UserList() []byte { + e := hessian.NewEncoder() + _ = e.Encode([]interface{}{ + {"wongoo"}, {"alex"}, + }) + return e.Buffer() +} diff --git a/output/testfuncs/user.go b/output/testfuncs/user.go new file mode 100644 index 000..03bb7df --- /dev/null +++ b/output/testfuncs/user.go @@ -0,0 +1,33 @@ +/* + * 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 testfuncs + +import hessian "github.com/apache/dubbo-go-hessian2" + +type User struct { + Name string +} + +// JavaClassName java fully qualified path +func (*User) JavaClassName() string { + return "test.model.User" +} + +func init() { + hessian.RegisterPOJO({}) +} diff --git a/test_hessian/src/main/java/test/model/User.java b/test_hessian/src/main/java/test/model/User.java new file mode 100644 index 000..a9f5e52 --- /dev/null +++ b/test_hessian/src/main/java/test/model/User.java @@ -0,0 +1,46 @@ +/* + * 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
[dubbo-go-hessian2] tag v1.9.2 created (now 3fddc30)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to tag v1.9.2 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. at 3fddc30 (commit) No new revisions were added by this update.
[dubbo-go-hessian2] branch master updated (b16a9bd -> 3fddc30)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. from b16a9bd Java.util.Locale support (#264) add 3fddc30 release note for v1.9.2 No new revisions were added by this update. Summary of changes: CHANGE.md | 5 + 1 file changed, 5 insertions(+)
[dubbo-go-hessian2] branch 1.9 updated (0d0b707 -> 3fddc30)
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a change to branch 1.9 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git. from 0d0b707 release note v1.9.1 add b16a9bd Java.util.Locale support (#264) new 3fddc30 release note for v1.9.2 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: CHANGE.md | 5 + java_util.go | 3 + java_util/README.md| 4 + java_util/README_CN.md | 5 + java_util/locale.go| 202 + java_util_test.go | 73 .../src/main/java/test/TestCustomReply.java| 56 -- 7 files changed, 336 insertions(+), 12 deletions(-) create mode 100644 java_util/locale.go
[dubbo-go-hessian2] 01/01: release note for v1.9.2
This is an automated email from the ASF dual-hosted git repository. wongoo pushed a commit to branch 1.9 in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git commit 3fddc30e53683f109c855210eea6178fd4400884 Author: wangoo AuthorDate: Wed Apr 21 08:10:12 2021 +0800 release note for v1.9.2 --- CHANGE.md | 5 + 1 file changed, 5 insertions(+) diff --git a/CHANGE.md b/CHANGE.md index b3fe541..8147c00 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,5 +1,10 @@ # Release Notes +## v1.9.2 + +### New Features +- support java.util.Locale. [#264](https://github.com/apache/dubbo-go-hessian2/pull/264) + ## v1.9.1 ### Bugfixes