You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/09/17 23:30:19 UTC

[GitHub] [geode] echobravopapa commented on a change in pull request #5525: GEODE-8506: BufferPool returns byte buffers that may be much larger t…

echobravopapa commented on a change in pull request #5525:
URL: https://github.com/apache/geode/pull/5525#discussion_r490616848



##########
File path: geode-core/src/main/java/org/apache/geode/internal/net/BufferPool.java
##########
@@ -98,14 +101,18 @@ private ByteBuffer acquireDirectBuffer(int size, boolean send) {
 
     if (useDirectBuffers) {
       if (size <= MEDIUM_BUFFER_SIZE) {
-        return acquirePredefinedFixedBuffer(send, size);
+        result = acquirePredefinedFixedBuffer(send, size);
       } else {
-        return acquireLargeBuffer(send, size);
+        result = acquireLargeBuffer(send, size);
       }
-    } else {
-      // if we are using heap buffers then don't bother with keeping them around
-      result = ByteBuffer.allocate(size);
+      if (result.capacity() > size) {
+        result.position(0).limit(size);
+        result = result.slice();

Review comment:
       👍 




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