You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2021/03/03 06:14:26 UTC
[rocketmq-client-go] branch v1.2.5 updated: fix string truncation
issue (#545)
This is an automated email from the ASF dual-hosted git repository.
lizhanhui pushed a commit to branch v1.2.5
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-go.git
The following commit(s) were added to refs/heads/v1.2.5 by this push:
new 60c2c2f fix string truncation issue (#545)
60c2c2f is described below
commit 60c2c2fe6391d7f8c657eb1f8764ff27f8db7364
Author: Zhanhui Li <li...@apache.org>
AuthorDate: Wed Mar 3 14:14:18 2021 +0800
fix string truncation issue (#545)
* fix string truncation issue
Co-authored-by: Li Zhanhui <li...@apache.org>
---
.travis.yml | 4 +++-
core/message.go | 6 +++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 99f27b5..84a339c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,7 +17,7 @@ env:
before_install:
- cd ${TRAVIS_HOME}
- - wget https://opensource-rocketmq-client-us.oss-us-west-1.aliyuncs.com/cpp-client/linux/1.2.4/RHEL7.x/librocketmq.tar.gz
+ - wget https://opensource-rocketmq-client-us.oss-us-west-1.aliyuncs.com/cpp-client/linux/1.2.5/RHEL7.x/librocketmq.tar.gz
- tar -xzf librocketmq.tar.gz
- sudo cp librocketmq.so librocketmq.a /usr/local/lib/
- sudo cp -r rocketmq /usr/local/include/
@@ -26,4 +26,6 @@ before_install:
script:
- export LD_LIBRARY_PATH=/usr/local/lib
- cd ${GOPATH}/src/github.com/apache/rocketmq-client-go
+ - go get github.com/sirupsen/logrus
+ - go get github.com/stretchr/testify/assert
- go test ./core
diff --git a/core/message.go b/core/message.go
index f6f4637..29ef2ec 100644
--- a/core/message.go
+++ b/core/message.go
@@ -64,7 +64,7 @@ func goMsgToC(gomsg *Message) *C.struct_CMessage {
C.free(unsafe.Pointer(cs))
cs = C.CString(gomsg.Body)
- C.SetMessageBody(cmsg, cs)
+ C.SetByteMessageBody(cmsg, cs, C.int(len(gomsg.Body)))
C.free(unsafe.Pointer(cs))
C.SetDelayTimeLevel(cmsg, C.int(gomsg.DelayTimeLevel))
@@ -85,7 +85,7 @@ func cMsgToGo(cMsg *C.struct_CMessage) *Message {
gomsg.Topic = C.GoString(C.GetOriginMessageTopic(cMsg))
gomsg.Tags = C.GoString(C.GetOriginMessageTags(cMsg))
gomsg.Keys = C.GoString(C.GetOriginMessageKeys(cMsg))
- gomsg.Body = C.GoString(C.GetOriginMessageBody(cMsg))
+ gomsg.Body = C.GoStringN(C.GetOriginMessageBody(cMsg), C.GetOriginMessageBodyLength(cMsg))
gomsg.DelayTimeLevel = int(C.GetOriginDelayTimeLevel(cMsg))
gomsg.cmsg = cMsg
@@ -129,7 +129,7 @@ func cmsgExtToGo(cmsg *C.struct_CMessageExt) *MessageExt {
gomsg.Topic = C.GoString(C.GetMessageTopic(cmsg))
gomsg.Tags = C.GoString(C.GetMessageTags(cmsg))
gomsg.Keys = C.GoString(C.GetMessageKeys(cmsg))
- gomsg.Body = C.GoString(C.GetMessageBody(cmsg))
+ gomsg.Body = C.GoStringN(C.GetMessageBody(cmsg), C.GetMessageBodyLength(cmsg))
gomsg.MessageID = C.GoString(C.GetMessageId(cmsg))
gomsg.DelayTimeLevel = int(C.GetMessageDelayTimeLevel(cmsg))
gomsg.QueueId = int(C.GetMessageQueueId(cmsg))