private Response toResponse()

in geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/jaxrs/HealthChecksEndpoint.java [64:82]


    private Response toResponse(final Function<HealthChecksRegistry, Collection<HealthCheck>> extractor,
                                final Consumer<HealthChecksRegistry> validate) {
        if (registry == null) {
            synchronized (this) {
                if (registry == null) {
                    registry = HealthChecksRegistry.load();
                }
            }
        }
        validate.accept(registry);

        final List<HealthCheckResponse> checks = extractor.apply(registry)
                .stream()
                .map(HealthCheck::call)
                .collect(toList());
        final HealthCheckResponse.Status globalState = checks.stream()
                .reduce(HealthCheckResponse.Status.UP, (a, b) -> combine(a, b.getStatus()), this::combine);
        return Response.status(globalState == HealthCheckResponse.Status.DOWN ? Response.Status.SERVICE_UNAVAILABLE : Response.Status.OK).entity(new AggregatedResponse(globalState, checks)).build();
    }