You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by jo...@apache.org on 2021/10/25 10:31:51 UTC
[dubbo-go-hessian2] branch master updated: support serialize UUID
to string (#285)
This is an automated email from the ASF dual-hosted git repository.
joezou 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 3a4ef0b support serialize UUID to string (#285)
3a4ef0b is described below
commit 3a4ef0be57cec0ab889e3a0b22e546df24e2e6a8
Author: zhangym <40...@users.noreply.github.com>
AuthorDate: Mon Oct 25 18:29:56 2021 +0800
support serialize UUID to string (#285)
support serialize UUID to string
Co-authored-by: zouyixian <zo...@shein.com>
Co-authored-by: wilson chen <wi...@gmail.com>
Co-authored-by: wangoo <wo...@apache.org>
---
java_util.go | 3 +--
java_util/uuid.go | 42 ++----------------------------------------
java_util_test.go | 2 +-
test_hessian/pom.xml | 2 +-
4 files changed, 5 insertions(+), 44 deletions(-)
diff --git a/java_util.go b/java_util.go
index 8dacc1f..30533a3 100644
--- a/java_util.go
+++ b/java_util.go
@@ -23,8 +23,7 @@ import (
func init() {
RegisterPOJO(&java_util.UUID{
- MostSigBits: int64(200),
- LeastSigBits: int64(200),
+ Value: "",
})
RegisterPOJO(&java_util.LocaleHandle{
Value: "",
diff --git a/java_util/uuid.go b/java_util/uuid.go
index b4ad3bf..844ed8c 100644
--- a/java_util/uuid.go
+++ b/java_util/uuid.go
@@ -17,14 +17,9 @@
package java_util
-import (
- "fmt"
-)
-
// java.util.UUID
type UUID struct {
- MostSigBits int64 `hessian:"mostSigBits"`
- LeastSigBits int64 `hessian:"leastSigBits"`
+ Value string `hessian:"value"`
}
func (UUID) JavaClassName() string {
@@ -32,39 +27,6 @@ func (UUID) JavaClassName() string {
}
//String returns a string object representing this UUID.
-//The UUID string representation is as described by this BNF:
-//
-// UUID = <time_low> "-" <time_mid> "-"
-// <time_high_and_version> "-"
-// <variant_and_sequence> "-"
-// <node>
-// time_low = 4*<hexOctet>
-// time_mid = 2*<hexOctet>
-// time_high_and_version = 2*<hexOctet>
-// variant_and_sequence = 2*<hexOctet>
-// node = 6*<hexOctet>
-// hexOctet = <hexDigit><hexDigit>
-// hexDigit =
-// "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
-// | "a" | "b" | "c" | "d" | "e" | "f"
-// | "A" | "B" | "C" | "D" | "E" | "F"
-//
-//Returns:
-//A string representation of this UUID
func (uuid UUID) String() string {
- uuidStr := fmt.Sprintf("%v-%v-%v-%v-%v",
- uuidDigits(uuid.MostSigBits>>32, 8),
- uuidDigits(uuid.MostSigBits>>16, 4),
- uuidDigits(uuid.MostSigBits, 4),
- uuidDigits(uuid.LeastSigBits>>48, 4),
- uuidDigits(uuid.LeastSigBits, 12),
- )
- return uuidStr
-}
-
-// uuidDigits returns arg represented by the specified number of hex digits.
-func uuidDigits(arg int64, digits uint) string {
- hi := int64(1) << (digits * 4)
- i := hi | (arg & (hi - 1))
- return fmt.Sprintf("%x", i)[1:]
+ return uuid.Value
}
diff --git a/java_util_test.go b/java_util_test.go
index 6a9028c..9bead22 100644
--- a/java_util_test.go
+++ b/java_util_test.go
@@ -37,7 +37,7 @@ func TestJavaUtil(t *testing.T) {
}
m := res.(map[interface{}]interface{})
- uuid1 := &java_util.UUID{LeastSigBits: int64(-7160773830801198154), MostSigBits: int64(459021424248441700)}
+ uuid1 := &java_util.UUID{Value: "065ec58d-a89f-4b64-9c9f-d223ea2e73b6"}
resUuid1 := m["uuid1"]
resUuid1String := m["uuid1_string"]
diff --git a/test_hessian/pom.xml b/test_hessian/pom.xml
index e6e185d..9074471 100644
--- a/test_hessian/pom.xml
+++ b/test_hessian/pom.xml
@@ -27,7 +27,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>hessian-lite</artifactId>
- <version>3.2.7</version>
+ <version>3.2.8</version>
<scope>compile</scope>
</dependency>
<dependency>