AlexStocks commented on code in PR #399:
URL: https://github.com/apache/dubbo-go-hessian2/pull/399#discussion_r3853113185
##########
null_test.go:
##########
@@ -132,5 +134,39 @@ func TestNullFieldStruct(t *testing.T) {
if e.Buffer() == nil {
t.Fail()
}
- assertEqual([]byte("NNNNN"), e.buffer[len(e.buffer)-5:], t)
+ assertEqual([]byte("NNNNNN"), e.buffer[len(e.buffer)-6:], t)
+}
+
+// Int64PtrFieldStruct verifies that a *int64 struct field is encoded as a
+// hessian long, so that a java consumer can deserialize it into a
+// java.lang.Long field, see apache/dubbo-go#2410.
+type Int64PtrFieldStruct struct {
+ Total *int64
+}
+
+func (*Int64PtrFieldStruct) JavaClassName() string {
+ return "Int64PtrFieldStruct"
+}
+
+func TestInt64PtrFieldStructEncode(t *testing.T) {
+ total := int64(12345)
+ e := NewEncoder()
+ if err := e.Encode(&Int64PtrFieldStruct{Total: &total}); err != nil {
+ t.Fatalf("encode Int64PtrFieldStruct: %v", err)
+ }
+ // 0x3c 0x30 0x39 is the hessian short-form long encoding of 12345
+ assertEqual([]byte{0x3c, 0x30, 0x39}, e.buffer[len(e.buffer)-3:], t)
+
+ d := NewDecoder(e.Buffer())
Review Comment:
[P2] 补一条独立 Java 消费者的字段对齐回归
这里检查的是对象尾部 compact-long 字节,并再交给同一套 Go POJO registry 解码;测试对象也只有一个字段,因此还没有直接复现
#2410 中 Java `Long` 字段后接其他类型字段时的错位。Encoder 和 Decoder 共享字段模型时可能同时接受同一种错误排列。仓库已有
`testJavaDecode` 和 Maven fixture,建议增加一个包含 `Long` 后接 `String` 的 Java POJO,分别覆盖
nil/non-nil 指针并断言 Java 侧两个字段;当前字节级断言可以继续保留为快速协议单测。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]