activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gaohoward <...@git.apache.org>
Subject [GitHub] activemq-artemis issue #1351: ARTEMIS-1220 Diverted LargeMessage file corrup...
Date Thu, 22 Jun 2017 00:18:50 GMT
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message