Github user gaohoward commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1351
  
    @clebertsuconic do you mean change the cited code piece to this:
    
    `
    for (;;) {
                byte[] bufferBytes = new byte[100 * 1024];
                ByteBuffer buffer = ByteBuffer.wrap(bufferBytes);
                // The buffer is reused...
                // We need to make sure we clear the limits and the buffer 
before reusing it
                buffer.clear();
                int bytesRead = file.read(buffer);
    
                byte[] bufferToWrite;
                if (bytesRead <= 0) {
                   break;
                } else {
                   //here, always make a copy
                   bufferToWrite = new byte[bytesRead];
                   System.arraycopy(bufferBytes, 0, bufferToWrite, 0, 
bytesRead);
                }
    
                newMessage.addBytes(bufferToWrite);
    
                if (bytesRead < bufferBytes.length) {
                   break;
                }
             }
    `
    I can see this is less efficient because if there is no replication 
(standalone broker without a backup) the copy is not necessary. The good about 
this is that it is simple and with largemessages the cost of copying seems not 
important (largemessages are slower than normal messages anyway).
    
    If the above understanding is right, I've no objection to making the 
changes.
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to