apache/dubbo-go-hessian2

Java服务端的LocalDateTime,Dubbo-Go客户端接收到的响应内容被转换成了map类型

wssjdi opened this issue · 5 comments

What would you like to be added:

Java Server PoJO:
private LocalDate birthday = LocalDate.now();
private java.sql.Time lastLoginTime = Time.valueOf("13:45:56");
private LocalDateTime registerDate = LocalDateTime.now();

Dubbo-Go Client Recive Response:
{
"birthday": {
"chronology": {
"calendarType": "iso8601",
"id": "ISO"
},
"dayOfMonth": 1,
"dayOfWeek": "MONDAY",
"dayOfYear": 1,
"era": "CE",
"leapYear": false,
"month": "JANUARY",
"monthValue": 1,
"year": 1900
},
"lastLoginTime": "1970-01-01T11:41:30+08:00",
"registerDate": {
"chronology": {
"calendarType": "iso8601",
"id": "ISO"
},
"dayOfMonth": 29,
"dayOfWeek": "WEDNESDAY",
"dayOfYear": 333,
"hour": 11,
"minute": 41,
"month": "NOVEMBER",
"monthValue": 11,
"nano": 0,
"second": 30,
"year": 2017
}
}
经测试发现在客户端接收到的响应内容中birthday、registerDate两个字段的类型为map,如此无法根据其字段类型,dubbo-go客户端做一些处理

Why is this needed:
如何在客户端将接收到的响应内容中的birthday、registerDate两个字段转换为struct类型(java8_time.LocalDateTime)或者ptr类型,而不是使用map类型?

在示例找到了java8_time.LocalDateTime的encode方法,没有找到对应的decode方法,后续版本是否会提供和JavaSqlTimeSerializer一样的序列化工具?

@wssjdi it support decoding LocalDateTime, ref the following link. I can't get why it does not work for you, u can provide more details, eg the full java pojo object, the definition of golang struct.

doTestTime(t, "java8_LocalDateTime", &java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 16}, Time: java8_time.LocalTime{Hour: 6, Minute: 5, Second: 4, Nano: 3}})

public static LocalDateTime java8_LocalDateTime() {

@wssjdi it support decoding LocalDateTime, ref the following link. I can't get why it does not work for you, u can provide more details, eg the full java pojo object, the definition of golang struct.

doTestTime(t, "java8_LocalDateTime", &java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 16}, Time: java8_time.LocalTime{Hour: 6, Minute: 5, Second: 4, Nano: 3}})

public static LocalDateTime java8_LocalDateTime() {

Thanks For Your Answer;
我项目中使用的是Dubbo-Go,Dubbo-go的最新版本1.5.5,依赖的dubbo-go-hessian2版本为v1.7.0,可能是版本过低原因导致的
image

@wssjdi it support decoding LocalDateTime, ref the following link. I can't get why it does not work for you, u can provide more details, eg the full java pojo object, the definition of golang struct.

doTestTime(t, "java8_LocalDateTime", &java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 16}, Time: java8_time.LocalTime{Hour: 6, Minute: 5, Second: 4, Nano: 3}})

public static LocalDateTime java8_LocalDateTime() {

Thanks For Your Answer;
我项目中使用的是Dubbo-Go,Dubbo-go的最新版本1.5.5,依赖的dubbo-go-hessian2版本为v1.7.0,可能是版本过低原因导致的
image

dubbo-go@1.5.5的部分依赖项:
... ...
github.com/apache/dubbo-go@v1.5.5 github.com/alibaba/sentinel-golang@v0.6.2
github.com/apache/dubbo-go@v1.5.5 github.com/apache/dubbo-getty@v1.3.10
github.com/apache/dubbo-go@v1.5.5 github.com/apache/dubbo-go-hessian2@v1.7.0
github.com/apache/dubbo-go@v1.5.5 github.com/coreos/etcd@v3.3.25+incompatible
github.com/apache/dubbo-go@v1.5.5 github.com/creasty/defaults@v1.5.1
github.com/apache/dubbo-go@v1.5.5 github.com/dubbogo/go-zookeeper@v1.0.2
github.com/apache/dubbo-go@v1.5.5 github.com/dubbogo/gost@v1.9.5
github.com/apache/dubbo-go@v1.5.5 github.com/elazarl/go-bindata-assetfs@v1.0.0
... ...

@wssjdi java8 time supported from v1.7.0, see https://github.com/apache/dubbo-go-hessian2/blob/1.8/CHANGE.md.
And u can upgrade hessian2 independently.