This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 02d8010196 Fixes #9051. Resolve camel.debug.enabled instead of testing 
for key presence
02d8010196 is described below

commit 02d801019615dcfe3da88e93b4d444c590ad93b4
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Sep 1 11:27:17 2026 +0200

    Fixes #9051. Resolve camel.debug.enabled instead of testing for key presence
    
    * Fixes #9051. Resolve camel.debug.enabled instead of testing for key 
presence
    
    CamelDebugProcessor gated its build steps on whether any property name 
started
    with "camel.debug", so camel.debug.enabled=false - a natural way to pin
    debugging off for a production build - still matched and still produced
    AllowJNDIBuildItem. Any unrelated camel.debug.* key did the same.
    
    Resolve the boolean value instead, and rename the supplier to 
CamelDebugEnabled
    so the name matches what it tests.
    
    DebugProcessor is deliberately left alone. Its read of the bare
    camel.debug.enabled property is the documented camel-main way to turn 
debugging
    on, covered by DebugEnabledFromCamelMainTest and relied on by the main and
    management integration tests.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    
    * Fixes #9051. Stop the debug gate test releasing the shared config
    
    CamelDebugEnabledTest drove the supplier through system properties, 
releasing
    the config registered for the class loader after each case so that SmallRye
    would re-read them. Surefire shares a JVM, so that left the following tests
    without a configuration and CamelDevModeProfileTest and
    CamelDevModeSingletonBeanTest both failed with
    
      SRCFG00015: No configuration is available for this class loader
    
    Running the class on its own passed, which is how it got through.
    
    Extract isDebugEnabled(Config) from the supplier so the test can build its 
own
    SmallRyeConfig per case and touch no global state. getAsBoolean() passes
    ConfigProvider.getConfig() into it, so behaviour is unchanged.
    
    The whole camel-quarkus-core-deployment suite now passes, 78 tests with no
    failures or errors.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    
    ---------
    
    Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
---
 .../core/deployment/CamelDebugProcessor.java       | 20 +++++--
 .../core/deployment/CamelDebugEnabledTest.java     | 70 ++++++++++++++++++++++
 2 files changed, 85 insertions(+), 5 deletions(-)

diff --git 
a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelDebugProcessor.java
 
b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelDebugProcessor.java
index 5ee593c439..81caa630b0 100644
--- 
a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelDebugProcessor.java
+++ 
b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelDebugProcessor.java
@@ -17,11 +17,11 @@
 package org.apache.camel.quarkus.core.deployment;
 
 import java.util.function.BooleanSupplier;
-import java.util.stream.StreamSupport;
 
 import io.quarkus.deployment.annotations.BuildStep;
 import io.quarkus.deployment.annotations.BuildSteps;
 import io.quarkus.deployment.builditem.AllowJNDIBuildItem;
+import org.eclipse.microprofile.config.Config;
 import org.eclipse.microprofile.config.ConfigProvider;
 
 /**
@@ -29,18 +29,28 @@ import org.eclipse.microprofile.config.ConfigProvider;
  * having the capability to enable debugging features that live in the Camel 
core such as the
  * DebuggerJmxConnectorService
  */
-@BuildSteps(onlyIf = CamelDebugProcessor.CamelDebugConfigurationPresent.class)
+@BuildSteps(onlyIf = CamelDebugProcessor.CamelDebugEnabled.class)
 public class CamelDebugProcessor {
     @BuildStep
     AllowJNDIBuildItem allowJNDI() {
         return new AllowJNDIBuildItem();
     }
 
-    static final class CamelDebugConfigurationPresent implements 
BooleanSupplier {
+    static final class CamelDebugEnabled implements BooleanSupplier {
         @Override
         public boolean getAsBoolean() {
-            return 
StreamSupport.stream(ConfigProvider.getConfig().getPropertyNames().spliterator(),
 false)
-                    .anyMatch(key -> key.startsWith("camel.debug"));
+            return isDebugEnabled(ConfigProvider.getConfig());
+        }
+
+        /**
+         * Resolves the value rather than testing whether any {@code 
camel.debug.*} key is present, so that pinning
+         * debugging off with {@code camel.debug.enabled=false} does not still 
allow JNDI.
+         *
+         * Takes the {@link Config} so that it can be exercised without 
touching the configuration registered for the
+         * class loader, which is shared with every other test in the JVM.
+         */
+        static boolean isDebugEnabled(Config config) {
+            return config.getOptionalValue("camel.debug.enabled", 
boolean.class).orElse(false);
         }
     }
 }
diff --git 
a/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/CamelDebugEnabledTest.java
 
b/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/CamelDebugEnabledTest.java
new file mode 100644
index 0000000000..567436586d
--- /dev/null
+++ 
b/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/CamelDebugEnabledTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.core.deployment;
+
+import java.util.Map;
+
+import io.smallrye.config.PropertiesConfigSource;
+import io.smallrye.config.SmallRyeConfigBuilder;
+import org.eclipse.microprofile.config.Config;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Each case builds its own {@link Config} rather than registering one for the 
class loader, so that nothing here
+ * disturbs the configuration the rest of the tests in this JVM rely on.
+ */
+public class CamelDebugEnabledTest {
+
+    private static final String CAMEL_DEBUG_ENABLED = "camel.debug.enabled";
+    private static final String CAMEL_DEBUG_OTHER = 
"camel.debug.logging-level";
+
+    @Test
+    public void notEnabledWhenUnconfigured() {
+        assertFalse(isDebugEnabled(Map.of()));
+    }
+
+    @Test
+    public void enabledWhenTrue() {
+        assertTrue(isDebugEnabled(Map.of(CAMEL_DEBUG_ENABLED, "true")));
+    }
+
+    @Test
+    public void notEnabledWhenExplicitlyFalse() {
+        assertFalse(isDebugEnabled(Map.of(CAMEL_DEBUG_ENABLED, "false")));
+    }
+
+    @Test
+    public void notEnabledByAnUnrelatedCamelDebugProperty() {
+        // A camel.debug.* key being present says nothing about whether 
debugging is on
+        assertFalse(isDebugEnabled(Map.of(CAMEL_DEBUG_OTHER, "INFO")));
+    }
+
+    @Test
+    public void notEnabledWhenFalseAlongsideAnotherCamelDebugProperty() {
+        assertFalse(isDebugEnabled(Map.of(CAMEL_DEBUG_ENABLED, "false", 
CAMEL_DEBUG_OTHER, "INFO")));
+    }
+
+    private static boolean isDebugEnabled(Map<String, String> properties) {
+        Config config = new SmallRyeConfigBuilder()
+                .withSources(new PropertiesConfigSource(properties, 
"CamelDebugEnabledTest", 100))
+                .build();
+        return CamelDebugProcessor.CamelDebugEnabled.isDebugEnabled(config);
+    }
+}

Reply via email to