httpcore5-testing/src/main/java/org/apache/hc/core5/testing/reactive/Reactive3TestUtils.java [83:116]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public static Flowable<ByteBuffer> produceStream(
            final long length,
            final int maximumBlockSize,
            final AtomicReference<String> hash
    ) {
        return Flowable.generate(new Consumer<Emitter<ByteBuffer>>() {
            final Random random = new Random(length); // Use the length as the random seed for easy reproducibility
            long bytesEmitted;
            final MessageDigest md = newMessageDigest();

            @Override
            public void accept(final Emitter<ByteBuffer> emitter) {
                final long remainingLength = length - bytesEmitted;
                if (remainingLength == 0) {
                    emitter.onComplete();
                    if (hash != null) {
                        hash.set(TextUtils.toHexString(md.digest()));
                    }
                } else {
                    final int bufferLength = (int) Math.min(remainingLength, 1 + random.nextInt(maximumBlockSize));
                    final byte[] bs = new byte[bufferLength];
                    for (int i = 0; i < bufferLength; i++) {
                        final byte b = RANGE[(int) (random.nextDouble() * RANGE.length)];
                        bs[i] = b;
                    }
                    if (hash != null) {
                        md.update(bs);
                    }
                    emitter.onNext(ByteBuffer.wrap(bs));
                    bytesEmitted += bufferLength;
                }
            }
        });
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



httpcore5-testing/src/main/java/org/apache/hc/core5/testing/reactive/ReactiveTestUtils.java [86:119]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public static Flowable<ByteBuffer> produceStream(
            final long length,
            final int maximumBlockSize,
            final AtomicReference<String> hash
    ) {
        return Flowable.generate(new Consumer<Emitter<ByteBuffer>>() {
            final Random random = new Random(length); // Use the length as the random seed for easy reproducibility
            long bytesEmitted;
            final MessageDigest md = newMessageDigest();

            @Override
            public void accept(final Emitter<ByteBuffer> emitter) {
                final long remainingLength = length - bytesEmitted;
                if (remainingLength == 0) {
                    emitter.onComplete();
                    if (hash != null) {
                        hash.set(TextUtils.toHexString(md.digest()));
                    }
                } else {
                    final int bufferLength = (int) Math.min(remainingLength, 1 + random.nextInt(maximumBlockSize));
                    final byte[] bs = new byte[bufferLength];
                    for (int i = 0; i < bufferLength; i++) {
                        final byte b = RANGE[(int) (random.nextDouble() * RANGE.length)];
                        bs[i] = b;
                    }
                    if (hash != null) {
                        md.update(bs);
                    }
                    emitter.onNext(ByteBuffer.wrap(bs));
                    bytesEmitted += bufferLength;
                }
            }
        });
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



