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 09:39:26 UTC

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

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


##########
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:
   LGTM



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