You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2020/03/25 06:56:37 UTC

[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3048: ARTEMIS-1975 Fixing LargeMessage encoding for replication

franz1981 commented on a change in pull request #3048: ARTEMIS-1975 Fixing LargeMessage encoding for replication
URL: https://github.com/apache/activemq-artemis/pull/3048#discussion_r397639669
 
 

 ##########
 File path: artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPLargeMessage.java
 ##########
 @@ -126,6 +127,20 @@ public void closeLargeMessage() throws Exception {
       parsingData = null;
    }
 
+   public synchronized void releaseEncodedBuffer() {
+      if (temporaryBuffer != null && temporaryBuffer.release()) {
+         temporaryBuffer = null;
+      }
+   }
+
+   public synchronized ByteBuf getSavedEncodeBuffer() {
+      if (temporaryBuffer == null) {
+         temporaryBuffer = PooledByteBufAllocator.DEFAULT.buffer(getEstimateSavedEncode());
+         saveEncoding(temporaryBuffer);
+      }
+      return temporaryBuffer.retain();
 
 Review comment:
   retain is a costly operation, is it necessary? Or we just document that the saved encode buffer cannot be conserved but just immediately used?
   I would document it anyway to save a user to forget to release it and cause memory leaks

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services