Closed qunxu closed 1 year ago
@qunxu v1.11.5 release, which fixed this issue. https://github.com/apache/dubbo-go-hessian2/releases/tag/v1.11.5
Can it be compatible with previous versions? I am currently using version 1.11.0 (or pre-1.11.5 version) for encoding and version 1.11.5 for decoding, but I still encounter panic when decoding empty type pointer slices.
What happened: 1.在同一个结构体里面有两种不同的指针切片的时候,如果切片两个都赋值为空切片,反序列化的时候会造成Panic。 2.在同一个结构体里面有两种不同的结构切片的时候,如果切片两个都赋值为空切片,反序列化后两个切片都会赋值为nil。 下面这段代码能复现这个结果 What you expected to happen: 1.反序列化回来两个空切片 2.反序列化回来两个空切片 How to reproduce it (as minimally and precisely as possible):
import ( hessian "github.com/apache/dubbo-go-hessian2" )
func init() { hessian.RegisterPOJO(new(SpPoint)) hessian.RegisterPOJO(new(Point)) hessian.RegisterPOJO(new(ReqInfo)) hessian.RegisterPOJO(new(ReqInfo2)) }
type SpPoint struct { X int Y int Sp int }
func (SpPoint) JavaClassName() string { return "com.test.SpPoint" }
type ReqInfo struct { Name string SpPoints []SpPoint Points []Point }
type ReqInfo2 struct { Name string SpPoints []SpPoint Points []Point }
func (ReqInfo2) JavaClassName() string { return "com.test.ReqInfo2" }
func (ReqInfo) JavaClassName() string { return "com.test.ReqInfo" }
func main() { d := ReqInfo{ Name: "test", SpPoints: []SpPoint{}, Points: []Point{}, } //d := ReqInfo2{ // Name: "test", // SpPoints: []SpPoint{}, // Points: []Point{}, //}
}
Anything else we need to know?: