leader318 opened a new pull request, #844:
URL: https://github.com/apache/rocketmq-clients/pull/844

   当消息体过大时,会进行压缩,不管是java的客户端还是 golang的客户端的压缩模式都一样,但是golang 
进行去取大数据并解压时,由于解压代码有问题,导致乱码问题
   
   修改的文件路径:golang/pkg/utils/utils.go
   
   原代码 :
   `func GZIPDecode(in []byte) ([]byte, error) {
        reader, err := gzip.NewReader(bytes.NewReader(in))
        if err != nil {
                var out []byte
                return out, err
        }
        defer reader.Close()
        return ioutil.ReadAll(reader)
   }`
   
   新增的方法:
   
   `func BytesGzipDecode(src []byte) ([]byte, error) {
        // Create a zlib reader
        byteArrayInputStream := bytes.NewReader(src)
        inflatesInputStream, err := zlib.NewReader(byteArrayInputStream)
        if err != nil {
                return nil, err
        }
        defer inflatesInputStream.Close()
        // Create a buffer to store decompressed data
        var byteArrayOutputStream bytes.Buffer
        _, err = io.Copy(&byteArrayOutputStream, inflatesInputStream)
        if err != nil {
                return nil, err
        }
        return byteArrayOutputStream.Bytes(), nil
   }`
   
   
   
   


-- 
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: commits-unsubscr...@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to