@Nullable
    public static ByteBuf accumulate(
            ByteBuf target, ByteBuf source, int targetAccumulationSize, int accumulatedSize) {
        if (accumulatedSize == 0 && source.readableBytes() >= targetAccumulationSize) {
            return source;
        }

        int copyLength = Math.min(source.readableBytes(), targetAccumulationSize - accumulatedSize);
        if (copyLength > 0) {
            target.writeBytes(source, copyLength);
        }

        if (accumulatedSize + copyLength == targetAccumulationSize) {
            return target;
        }

        return null;
    }
@Test
    void testAccumulateWithoutCopy() {
        int sourceLength = 128;
        int sourceReaderIndex = 32;
        int expectedAccumulationSize = 16;

        ByteBuf src = createSourceBuffer(sourceLength, sourceReaderIndex, expectedAccumulationSize);
        ByteBuf target = Unpooled.buffer(expectedAccumulationSize);

        // If src has enough data and no data has been copied yet, src will be returned without
        // modification.
        ByteBuf accumulated =
                ByteBufUtils.accumulate(
                        target, src, expectedAccumulationSize, target.readableBytes());

        assertThat(accumulated).isSameAs(src);
        assertThat(src.readerIndex()).isEqualTo(sourceReaderIndex);
        verifyBufferContent(src, sourceReaderIndex, expectedAccumulationSize);
    }