private ByteBuffer getBuffer(final int expectSize) {
        if (this.buffer == null) {
            this.buffer = Utils.allocate(expectSize);
        } else if (this.buffer.remaining() < expectSize) {
            this.buffer = Utils.expandByteBufferAtLeast(this.buffer, expectSize);
        }
        return this.buffer;
    }
A byte buffer collector that will expand automatically.

@author dennis
jraft-core/src/main/java/com/alipay/sofa/jraft/util/ByteBufferCollector.java