maixiaohai commented on a change in pull request #765:
URL: https://github.com/apache/rocketmq-client-go/pull/765#discussion_r775860371



##########
File path: internal/model.go
##########
@@ -295,12 +295,39 @@ type ResetOffsetBody struct {
        OffsetTable map[primitive.MessageQueue]int64 `json:"offsetTable"`
 }
 
+// Decode note: the origin implementation for parse json is in gson format.
+// this func should support both gson and fastjson schema.
 func (resetOffsetBody *ResetOffsetBody) Decode(body []byte) {
+       validJSON := gjson.ValidBytes(body)
+
+       var offsetTable map[primitive.MessageQueue]int64
+
+       if validJSON {
+               offsetTable = parseGsonFormat(body)
+       } else {
+               offsetTable = parseFastJsonFormat(body)
+       }
+
+       resetOffsetBody.OffsetTable = offsetTable
+}
+
+func parseGsonFormat(body []byte) map[primitive.MessageQueue]int64 {
        result := gjson.ParseBytes(body)
+
        rlog.Debug("offset table string "+result.Get("offsetTable").String(), 
nil)
 
        offsetTable := make(map[primitive.MessageQueue]int64, 0)
-       offsetTableArray := strings.Split(result.Get("offsetTable").String(), 
"],[")
+
+       offsetStr := result.Get("offsetTable").String()
+       if len(offsetStr) <= 2 {

Review comment:
       请教下,何时会触发这个情况




-- 
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]


Reply via email to