@Override
    @SuppressWarnings("unchecked")
    public HttpResponse convertResponse(ServiceRequestContext ctx, ResponseHeaders headers,
                                        @Nullable Object result, HttpHeaders trailers) throws Exception {
        final CompletableFuture<?> f;
        if (result instanceof Publisher) {
            f = collectFrom((Publisher<Object>) result, ctx);
        } else if (result instanceof Stream) {
            f = collectFrom((Stream<Object>) result, ctx.blockingTaskExecutor());
        } else {
            return ResponseConverterFunction.fallthrough();
        }

        return HttpResponse.of(f.thenApply(aggregated -> {
            try {
                return responseConverter.convertResponse(ctx, headers, aggregated, trailers);
            } catch (Exception ex) {
                return Exceptions.throwUnsafely(ex);
            }
        }));
    }
A response converter implementation which creates an {@link HttpResponse} with
the objects published from a {@link Publisher} or {@link Stream}.
core/src/main/java/com/linecorp/armeria/internal/server/annotation/AggregatedResponseConverterFunction.java