@Override
    public HttpResponse convertResponse(ServiceRequestContext ctx,
                                        ResponseHeaders headers,
                                        @Nullable Object result,
                                        HttpHeaders trailers) throws Exception {
        if (result instanceof HttpResponse) {
            return (HttpResponse) result;
        }

        if (result instanceof ResponseEntity) {
            final ResponseEntity<?> responseEntity = (ResponseEntity<?>) result;
            headers = ResponseEntityUtil.buildResponseHeaders(ctx, responseEntity);
            result = responseEntity.hasContent() ? responseEntity.content() : null;
            trailers = responseEntity.trailers();
        } else if (result instanceof HttpResult) {
            final HttpResult<?> httpResult = (HttpResult<?>) result;
            headers = HttpResultUtil.buildResponseHeaders(ctx, httpResult);
            result = httpResult.content();
            trailers = httpResult.trailers();
        }
        try (SafeCloseable ignored = ctx.push()) {
            for (final ResponseConverterFunction func : functions) {
                try {
                    return func.convertResponse(ctx, headers, result, trailers);
                } catch (FallthroughException ignore) {
                    // Do nothing.
                } catch (Exception e) {
                    throw new IllegalStateException(
                            "Response converter " + func.getClass().getName() +
                            " cannot convert a result to HttpResponse: " + result, e);
                }
            }
        }
        // There is no response converter which is able to convert 'null' result to a response.
        // In this case, a response with the specified HTTP headers would be sent.
        // If you want to force to send '204 No Content' for this case, add
        // 'NullToNoContentResponseConverterFunction' to the list of response converters.
        if (result == null) {
            return HttpResponse.of(headers, HttpData.empty(), trailers);
        }
        throw new IllegalStateException(
                "No response converter exists for a result: " + result.getClass().getName());
    }
A {@link ResponseConverterFunction} which wraps a list of {@link ResponseConverterFunction}s.
core/src/main/java/com/linecorp/armeria/internal/server/annotation/CompositeResponseConverterFunction.java