final int bufferSize = calcWriteBufferSize(connection, buffer.remaining());
buffer.limit(oldPos + bufferSize);
final DirectByteBufferRecord ioRecord =
DirectByteBufferRecord.get();
final ByteBuffer directByteBuffer = ioRecord.allocate(bufferSize);
fill(buffer, bufferSize, directByteBuffer);
try {
written = flushByteBuffer(socketChannel, directByteBuffer);
} finally {