protonj2/src/main/java/org/apache/qpid/protonj2/buffer/netty/Netty4ToProtonBufferAdapter.java [1086:1104]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private void expandOrThrowError(int index, int size, boolean mayExpand) {
        if (readCapacity == CLOSED_MARKER) {
            throw ProtonBufferUtils.genericBufferIsClosed(this);
        }

        if (readOnly) {
            throw ProtonBufferUtils.genericBufferIsReadOnly(this);
        }

        int capacity = capacity();
        if (mayExpand && index >= 0 && index <= capacity && writeOffset + size <= implicitGrowthLimit) {
            int minimumGrowth = Math.min(Math.max(capacity * 2, size), implicitGrowthLimit) - capacity;
            ensureWritable(size, minimumGrowth, false);
            checkSet(index, size); // Verify writing is now possible, without recursing.
            return;
        }

        throw ProtonBufferUtils.genericOutOfBounds(this, index);
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



protonj2/src/main/java/org/apache/qpid/protonj2/buffer/impl/ProtonByteArrayBuffer.java [1018:1036]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private void expandOrThrowError(int index, int size, boolean mayExpand) {
        if (readCapacity == CLOSED_MARKER) {
            throw ProtonBufferUtils.genericBufferIsClosed(this);
        }

        if (readOnly) {
            throw ProtonBufferUtils.genericBufferIsReadOnly(this);
        }

        int capacity = capacity();
        if (mayExpand && index >= 0 && index <= capacity && writeOffset + size <= implicitGrowthLimit) {
            int minimumGrowth = Math.min(Math.max(capacity * 2, size), implicitGrowthLimit) - capacity;
            ensureWritable(size, minimumGrowth, false);
            checkSet(index, size); // Verify writing is now possible, without recursing.
            return;
        }

        throw ProtonBufferUtils.genericOutOfBounds(this, index);
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



