You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/02/20 10:00:46 UTC

[camel] branch main updated: CAMEL-17672: camel-main - Health is optional so we should not WARN about camel-health not on classpath.

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 a46fa74  CAMEL-17672: camel-main - Health is optional so we should not WARN about camel-health not on classpath.
a46fa74 is described below

commit a46fa7401bfa3f949af4fbd65b7ae3b87e147906
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Feb 20 11:00:07 2022 +0100

    CAMEL-17672: camel-main - Health is optional so we should not WARN about camel-health not on classpath.
---
 .../java/org/apache/camel/main/BaseMainSupport.java  | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index af84a12..e43c66d 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -1003,17 +1003,25 @@ public abstract class BaseMainSupport extends BaseService {
             boolean failIfNotSet, Map<String, String> autoConfiguredProperties)
             throws Exception {
 
-        HealthCheckRegistry hcr = camelContext.getExtension(HealthCheckRegistry.class);
-        if (hcr == null) {
-            LOG.warn("Cannot find HealthCheckRegistry from classpath. Add camel-health to classpath.");
-            return;
-        }
-
         HealthConfigurationProperties health = mainConfigurationProperties.health();
 
         setPropertiesOnTarget(camelContext, health, healthCheckProperties, "camel.health.",
                 mainConfigurationProperties.isAutoConfigurationFailFast(), true, autoConfiguredProperties);
 
+        if (health.getEnabled() != null && !health.getEnabled()) {
+            // health-check is disabled
+            return;
+        }
+
+        // auto-detect camel-health on classpath
+        HealthCheckRegistry hcr = camelContext.getExtension(HealthCheckRegistry.class);
+        if (hcr == null) {
+            if (health.getEnabled() != null && health.getEnabled()) {
+                LOG.warn("Cannot find HealthCheckRegistry from classpath. Add camel-health to classpath.");
+            }
+            return;
+        }
+
         if (health.getEnabled() != null) {
             hcr.setEnabled(health.getEnabled());
         }