apache / dubbo-go-hessian2

caucho hessian2 implementation in Go for [apache/dubbo-go](https://github.com/apache/dubbo-go) which is compatible with [dubbo-hessian-lite](https://github.com/apache/dubbo-hessian-lite)
Apache License 2.0
209 stars 113 forks source link

json string decode 数据有误 #272

Closed SocketNet closed 3 years ago

SocketNet commented 3 years ago

Java 对象

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ImRequestMsgBody {
    private String url;
    private Map<String, Object> params;
}

转 JSON字符串后通过 Hessian2Output 序列化,得到以下数据

1;{"params":{"fromAccid":"23495382","msgType":100,"msgId":"148ef1b2-808d-48f2-b268-7a1018a27bdb","attach":"{\"accid\":\"23495382\",\"classRoomFlag\":50685,\"msgId\":\"599645021431398400\",\"msgType\":\"100\",\"nickname\":\"橙子������\"}","roomid":413256699},"url":"https://api.netease.im/nimserver/chatroom/sendMsg.action"}

Go 还原后得到以下数据


func stringHessianDecode(data []byte) (string, error) {
    decode := hessian.NewDecoder(data)
    res, err := decode.Decode()
    if err != nil {
        return "", err
    }
    return res.(string), nil
}

{"params":{"fromAccid":"23495382","msgType":100,"msgId":"148ef1b2-808d-48f2-b268-7a1018a27bdb","attach":"{\"accid\":\"23495382\",\"classRoomFlag\":50685,\"msgId\":\"599645021431398400\",\"msgType\":\"100\",\"nickname\":\"橙子������\"}","roomid":413256699},"url":"https://api.netease.im/nimserver/chatroom/sendMsg.acti

无法还原Java通过Hessian2Output Encode前的JsonString

wongoo commented 3 years ago

@SocketNet 你的意思是反序列化后得到的字符串有丢失吗?

SocketNet commented 3 years ago

是的,部分丢失。并不是所有字符串都有问题。昨天上线后10w的消息里至少1k条是有问题的。需要的话,这边可以提供更多数据

wongoo commented 3 years ago

@SocketNet 加了单元测试是可以的,你看看是不是可以模拟出问题? https://github.com/apache/dubbo-go-hessian2/pull/273

SocketNet commented 3 years ago

👍好的,我今天找时间验证下

wongoo commented 3 years ago

@SocketNet 有找到问题吗?