You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by go...@apache.org on 2021/11/23 01:57:17 UTC
[incubator-inlong] branch master updated: [INLONG-1828]Fix bug when parsing tdmsg v1 in Go SDK (#1829)
This is an automated email from the ASF dual-hosted git repository.
gosonzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 95c5232 [INLONG-1828]Fix bug when parsing tdmsg v1 in Go SDK (#1829)
95c5232 is described below
commit 95c5232735f217132537650211c94db4e7441b3b
Author: Zijie Lu <ws...@gmail.com>
AuthorDate: Tue Nov 23 09:57:12 2021 +0800
[INLONG-1828]Fix bug when parsing tdmsg v1 in Go SDK (#1829)
Signed-off-by: Zijie Lu <ws...@gmail.com>
---
.../tubemq-client-twins/tubemq-client-go/tdmsg/td_msg.go | 2 +-
.../tubemq-client-twins/tubemq-client-go/tdmsg/td_msg_test.go | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/inlong-tubemq/tubemq-client-twins/tubemq-client-go/tdmsg/td_msg.go b/inlong-tubemq/tubemq-client-twins/tubemq-client-go/tdmsg/td_msg.go
index cfd61b4..324d14b 100644
--- a/inlong-tubemq/tubemq-client-twins/tubemq-client-go/tdmsg/td_msg.go
+++ b/inlong-tubemq/tubemq-client-twins/tubemq-client-go/tdmsg/td_msg.go
@@ -281,7 +281,7 @@ func (m *TubeMQTDMsg) parseDefaultBody(data []byte, ver int32) error {
if itemRem < 4 {
return errs.New(errs.RetTDMsgParseFailure, fmt.Sprintf("parse message error: no enough data length for v%d item's msgLength parameter", ver))
}
- di, err := parseDataItem(data[itemPos : itemPos+itemRem])
+ di, err := parseDataItem(body[itemPos : itemPos+itemRem])
if err != nil {
return err
}
diff --git a/inlong-tubemq/tubemq-client-twins/tubemq-client-go/tdmsg/td_msg_test.go b/inlong-tubemq/tubemq-client-twins/tubemq-client-go/tdmsg/td_msg_test.go
index 936df5b..1e8408d 100644
--- a/inlong-tubemq/tubemq-client-twins/tubemq-client-go/tdmsg/td_msg_test.go
+++ b/inlong-tubemq/tubemq-client-twins/tubemq-client-go/tdmsg/td_msg_test.go
@@ -32,3 +32,12 @@ func TestTDMsgV4(t *testing.T) {
assert.Equal(t, uint32(1), tm.MsgCount)
assert.Equal(t, false, tm.IsNumBid)
}
+
+func TestTDMsgV1(t *testing.T) {
+ b := []byte{15,1,0,0,1,125,71,98,161,138,0,0,0,1,0,206,100,116,61,49,54,51,55,53,56,48,49,56,53,57,56,55,38,109,115,103,85,85,73,68,61,100,98,52,97,51,101,51,100,45,50,100,101,55,45,52,99,102,102,45,56,54,97,101,45,98,53,55,52,55,101,57,49,98,51,101,53,38,99,110,116,61,49,38,109,116,61,112,98,38,78,111,100,101,73,80,61,49,49,46,49,53,52,46,50,48,57,46,49,55,57,38,114,116,61,49,54,51,55,53,56,48,49,56,53,57,57,52,38,109,61,57,38,116,105,100,61,116,95,115,110,103,95,103,100,116,95,117,110 [...]
+ tm, err := New(b)
+ assert.Equal(t, uint64(1637580185994), tm.CreateTime)
+ assert.Equal(t, int32(1), tm.Version)
+ assert.Equal(t, false, tm.IsNumBid)
+ assert.Nil(t, err)
+}