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

ASF GitHub Bot commented on ARTEMIS-2059:
-----------------------------------------

Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/2274
  
    @tabish121 @gemmellr I will be probably able to take a further look on it 
after wednesday...
    Anyway I think that this PR as it is will just fix the bug at a performance 
cost: ByteBufUtil.utf8Bytes has a O(n) cost while ByteBufUtil.utf8MaxBytes is 
O(1).
    A trivial fix with no performance hit that assume that the ByteBuffer has 
been sized with enough space to hold the encoded string would be to use 
```ByteBufUtil.reserveAndWriteUtf8(nettyBuffer, value, 
nettyBuffer.writableBytes());``` instead, but I'm not sure if 
NettyWritable::put(String) can safely assume it.



> NettyWritable should use UTF-8 exact length to encode strings
> -------------------------------------------------------------
>
>                 Key: ARTEMIS-2059
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2059
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: AMQP
>            Reporter: Francesco Nigro
>            Assignee: Francesco Nigro
>            Priority: Minor
>             Fix For: 2.7.0
>
>
> NettyWritable.put(String) tries to enlarge the buffer used to write a UTF-8 
> string until ByteBufUtil.utf8MaxBytes.
> That means that it will fail or will enlarge any ByteBuf that is perfectly 
> sized to contain the encoded string.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to