[ 
https://issues.apache.org/jira/browse/ROCKETMQ-166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16004006#comment-16004006
 ] 

ASF GitHub Bot commented on ROCKETMQ-166:
-----------------------------------------

Github user lizhanhui commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq/pull/89#discussion_r115650129
  
    --- Diff: 
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java ---
    @@ -306,6 +310,19 @@ public SendResult sendMessage(//
             final SendMessageContext context, // 11
             final DefaultMQProducerImpl producer // 12
         ) throws RemotingException, MQBrokerException, InterruptedException {
    +
    +        byte[] msgBody = msg.getBody();
    +        Integer sysFlag = requestHeader.getSysFlag();
    +        if (null != sysFlag && ((sysFlag & MessageSysFlag.COMPRESSED_FLAG) 
== MessageSysFlag.COMPRESSED_FLAG)) {
    +            try {
    +                msgBody = UtilAll.compress(msgBody, zipCompressLevel);
    +            } catch (IOException e) {
    +                
requestHeader.setSysFlag(MessageSysFlag.clearCompressedFlag(sysFlag));
    +                log.error("tryToCompressMessage exception", e);
    --- End diff --
    
    You mean why we log error on failing to compress message body?  


> onException callback may capture compressed message body
> --------------------------------------------------------
>
>                 Key: ROCKETMQ-166
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-166
>             Project: Apache RocketMQ
>          Issue Type: Bug
>          Components: rocketmq-client
>    Affects Versions: 4.0.0-incubating, 4.1.0-incubating
>            Reporter: Zhanhui Li
>            Assignee: Zhanhui Li
>             Fix For: 4.1.0-incubating
>
>
> If message body size exceeds specified threshold, client would try to 
> compress the message body. 
> Here there are two issues: 1) current implementation changes message body 
> directly, which is not a good practice; 2) if asynchronous send method is 
> employed to deliver message, when onException is invoked, the callback may 
> capture the compressed message body before the finally block restores it.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to