This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new bc1a5aa Polished
bc1a5aa is described below
commit bc1a5aa2fc7a5efbaeabfa6ab78f83bb0bdbfb20
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Mar 25 14:21:41 2022 +0100
Polished
---
.../org/apache/camel/health/HealthCheckHelper.java | 19 +++++++++++++++++++
.../java/org/apache/camel/main/VertxHttpServer.java | 9 +--------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git
a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java
b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java
index ba5c28d..431f09d 100644
---
a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java
+++
b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java
@@ -265,6 +265,25 @@ public final class HealthCheckHelper {
}
/**
+ * Checks the overall status of the results.
+ *
+ * @param results the results from the invoked health checks
+ * @param readiness readiness or liveness mode
+ * @return true if up, or false if down
+ */
+ public static boolean isResultsUp(Collection<HealthCheck.Result> results,
boolean readiness) {
+ boolean up;
+ if (readiness) {
+ // readiness requires that all are UP
+ up = results.stream().allMatch(r ->
r.getState().equals(HealthCheck.State.UP));
+ } else {
+ // liveness will fail if there is any down
+ up = results.stream().noneMatch(r ->
r.getState().equals(HealthCheck.State.DOWN));
+ }
+ return up;
+ }
+
+ /**
* Get the group of the given check or an empty string if the group is not
set.
*
* @param check the health check
diff --git
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/VertxHttpServer.java
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/VertxHttpServer.java
index adc3bf2..63d71b4 100644
---
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/VertxHttpServer.java
+++
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/VertxHttpServer.java
@@ -228,14 +228,7 @@ public final class VertxHttpServer {
}
// are we UP
- boolean up;
- if (rdy) {
- // readiness requires that all are UP
- up = res.stream().allMatch(r ->
r.getState().equals(HealthCheck.State.UP));
- } else {
- // liveness will fail if there is any down
- up = res.stream().noneMatch(r ->
r.getState().equals(HealthCheck.State.DOWN));
- }
+ boolean up = HealthCheckHelper.isResultsUp(res, rdy);
if ("oneline".equals(level)) {
// only brief status