Run checks in parallel The execution and check of the result of the individual checks were made in a serial stream processing, which means that the healthcheck endpoint could have actually failed even if the individual healthchecks would have all completed in a timely manner. Introduce the parallel processing of the stream so that all checks are running in parallel and have more chances to be completed within the expected timeout from the load balancer. Change-Id: Ibbcbbc429bab8c4694f626478a1e7832eac6f64b
diff --git a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/GlobalHealthCheck.java b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/GlobalHealthCheck.java index fa5f14a..d955e47 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/GlobalHealthCheck.java +++ b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/GlobalHealthCheck.java
@@ -48,7 +48,7 @@ Iterable<HealthCheck> iterable = () -> healthChecks.iterator(); long ts = System.currentTimeMillis(); Map<String, Object> checkToResults = - StreamSupport.stream(iterable.spliterator(), false) + StreamSupport.stream(iterable.spliterator(), true) .map(check -> Arrays.asList(check.name(), check.run())) .collect(Collectors.toMap(k -> (String) k.get(0), v -> v.get(1))); long elapsed = System.currentTimeMillis() - ts;