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 2021/02/22 05:57:45 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #9667: [Compression] Fix ByteBuffer allocate error in the AirliftUtils

eolivelli commented on a change in pull request #9667:
URL: https://github.com/apache/pulsar/pull/9667#discussion_r580000333



##########
File path: pulsar-common/src/main/java/org/apache/pulsar/common/compression/AirliftUtils.java
##########
@@ -25,10 +25,10 @@
  */
 public abstract class AirliftUtils {
 
-    static ByteBuffer ensureAirliftSupported(ByteBuffer encodedNio, int uncompressedLength) {
+    static ByteBuffer ensureAirliftSupported(ByteBuffer encodedNio) {
         if (!encodedNio.isDirect() && !encodedNio.hasArray()) {
             // airlift needs a raw ByteArray
-            ByteBuffer copy = ByteBuffer.allocate(uncompressedLength);
+            ByteBuffer copy = ByteBuffer.allocate(encodedNio.capacity());

Review comment:
       I am not sure I understand the fix here.
   'uncompressedLength' may be usually bigger than the size of the buffer passed to this method, because data is compressed.
   
   What about using the 'max' between the two values?
   




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