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 a45598e CAMEL-17839: camel-health - Allow to configure initial state
of health-checks (readiness). This mostly affect scheduled consumers which can
be in either DOWN or UNKNOWN state before doing their first poll. By default we
are careful and report as DOWN as we are not ready. But this allows users to
not care and set it as UP or UNKNOWN.
a45598e is described below
commit a45598e3c157ec42f4b695ab459c80e7eb314267
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Mar 25 09:27:05 2022 +0100
CAMEL-17839: camel-health - Allow to configure initial state of
health-checks (readiness). This mostly affect scheduled consumers which can be
in either DOWN or UNKNOWN state before doing their first poll. By default we
are careful and report as DOWN as we are not ready. But this allows users to
not care and set it as UP or UNKNOWN.
---
.../src/main/java/org/apache/camel/health/HealthCheckRegistry.java | 2 +-
.../main/java/org/apache/camel/impl/health/AbstractHealthCheck.java | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git
a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckRegistry.java
b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckRegistry.java
index 083b899..ac5cb1b 100644
---
a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckRegistry.java
+++
b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckRegistry.java
@@ -108,7 +108,7 @@ public interface HealthCheckRegistry extends
CamelContextAware, StaticService, I
* could integrate such checks within its health endpoint or make it
available only as separate endpoint.
*/
static HealthCheckRegistry get(CamelContext context) {
- return context.getExtension(HealthCheckRegistry.class);
+ return context != null ?
context.getExtension(HealthCheckRegistry.class) : null;
}
/**
diff --git
a/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java
b/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java
index c29ef1d..3b1767a 100644
---
a/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java
+++
b/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java
@@ -131,7 +131,9 @@ public abstract class AbstractHealthCheck implements
HealthCheck, CamelContextAw
// set initial state
final HealthCheckRegistry registry =
HealthCheckRegistry.get(camelContext);
- builder.state(registry.getInitialState());
+ if (registry != null) {
+ builder.state(registry.getInitialState());
+ }
// what kind of check is this
HealthCheck.Kind kind;