CompletableFuture<Void> feedMany(InputStream jsonStream, int size, ResultCallback resultCallback) {
        if (closed) throw new IllegalStateException("Already closed");
        CompletableFuture<Void> overallResult = new CompletableFuture<>();
        CompletableFuture<Result> result;
        AtomicInteger localInflightOperations = new AtomicInteger(1); // The below dispatch loop itself is counted as a single pending operation
        AtomicBoolean finalCallbackInvoked = new AtomicBoolean();
        try (RingBufferStream buffer = new RingBufferStream(jsonStream, size)) {
            while ((result = buffer.next()) != null) {
                localInflightOperations.incrementAndGet();
                globalInflightOperations.incrementAndGet();
                result.whenCompleteAsync((r, t) -> {
                    if (!finalCallbackInvoked.get()) {
                        invokeCallback(resultCallback, c -> c.onNextResult(r, (FeedException) t));
                    }
                    if (localInflightOperations.decrementAndGet() == 0 && finalCallbackInvoked.compareAndSet(false, true)) {
                        invokeCallback(resultCallback, ResultCallback::onComplete);
                        overallResult.complete(null);
                    }
                    globalInflightOperations.decrementAndGet();
                }, resultExecutor);
            }
            if (localInflightOperations.decrementAndGet() == 0 && finalCallbackInvoked.compareAndSet(false, true)) {
                resultExecutor.execute(() -> {
                    invokeCallback(resultCallback, ResultCallback::onComplete);
                    overallResult.complete(null);
                });
            }
        } catch (Exception e) {
            if (finalCallbackInvoked.compareAndSet(false, true)) {
                resultExecutor.execute(() -> {
                    FeedException wrapped = wrapException(e);
                    invokeCallback(resultCallback, c -> c.onError(wrapped));
                    overallResult.completeExceptionally(wrapped);
                });
            }
        }
        return overallResult;
    }
Same as {@link #feedMany(InputStream, ResultCallback)}, but without a provided {@link ResultCallback} instance.
@see JsonFeeder#feedMany(InputStream, ResultCallback) for details.
vespa-feed-client-api/src/main/java/ai/vespa/feed/client/JsonFeeder.java