dschneider-pivotal commented on code in PR #7621:
URL: https://github.com/apache/geode/pull/7621#discussion_r859090971
##########
geode-core/src/main/java/org/apache/geode/internal/net/BufferPool.java:
##########
@@ -90,46 +87,46 @@ static boolean computeUseDirectBuffers() {
*
* @return a byte buffer to be used for sending on this connection.
*/
- public ByteBuffer acquireDirectSenderBuffer(int size) {
+ public PooledByteBuffer acquireDirectSenderBuffer(int size) {
return acquireDirectBuffer(size, true);
}
- public ByteBuffer acquireDirectReceiveBuffer(int size) {
+ public PooledByteBuffer acquireDirectReceiveBuffer(int size) {
return acquireDirectBuffer(size, false);
}
/**
* try to acquire direct buffer, if enabled by configuration
*/
- private ByteBuffer acquireDirectBuffer(int size, boolean send) {
- ByteBuffer result;
+ private PooledByteBuffer acquireDirectBuffer(int size, boolean send) {
+ ByteBuffer byteBuffer;
if (useDirectBuffers) {
if (size <= MEDIUM_BUFFER_SIZE) {
- result = acquirePredefinedFixedBuffer(send, size);
+ byteBuffer = acquirePredefinedFixedBuffer(send, size);
} else {
- result = acquireLargeBuffer(send, size);
+ byteBuffer = acquireLargeBuffer(send, size);
}
- if (result.capacity() > size) {
- result.position(0).limit(size);
- result = result.slice();
+ if (byteBuffer.capacity() > size) {
+ byteBuffer.position(0).limit(size);
+ return new PooledByteBuffer(byteBuffer, byteBuffer.slice());
Review Comment:
Also keep in mind that half of the users of BufferPool get a buffer and hold
onto for an extended time. In those cases the PooledByteBuffer is not transient.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]