public ByteBuf allocateBuffer(ByteBufAllocator allocator) {
    if (configuration.isPreferDirectBuffer()) {
      return allocator.ioBuffer();
    }

    return allocator.heapBuffer();
  }