You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/15 15:28:18 UTC

[GitHub] [pulsar] merlimat commented on a diff in pull request #17663: [fix][client]Fix Producer exceeds PulsarClient memory limit when sending fail timeout using CompressionType.NONE

merlimat commented on code in PR #17663:
URL: https://github.com/apache/pulsar/pull/17663#discussion_r972135652


##########
pulsar-common/src/main/java/org/apache/pulsar/common/compression/CompressionCodecNone.java:
##########
@@ -28,8 +29,15 @@ public class CompressionCodecNone implements CompressionCodec {
 
     @Override
     public ByteBuf encode(ByteBuf raw) {
-        // Provides an encoder that simply returns the same uncompressed buffer
-        return raw.retain();
+        int readableBytes = raw.readableBytes();
+        if (readableBytes == raw.capacity()) {
+            return raw.retain();
+        }
+        raw.markReaderIndex();
+        ByteBuf target = PulsarByteBufAllocator.DEFAULT.buffer(readableBytes, readableBytes);
+        target.writeBytes(raw);
+        raw.resetReaderIndex();
+        return target;

Review Comment:
   I don't think this is the right solution because it would cause a memory copy for all the batches. 
   



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org