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 ded189c0a9 [fixes #5675] Fix order of applying system properties to
camel main
ded189c0a9 is described below
commit ded189c0a9d855d8746c7513d6f08d800f4ffbe2
Author: Lukas Lowinger <[email protected]>
AuthorDate: Wed Aug 20 13:19:45 2025 +0200
[fixes #5675] Fix order of applying system properties to camel main
---
.../jasypt/deployment/JasyptProcessor.java | 11 +++--
.../component/jasypt/CamelJasyptRecorder.java | 47 +++++++++++++++++++---
.../jasypt/it/JasyptSecureExtensionConfigTest.java | 2 -
3 files changed, 46 insertions(+), 14 deletions(-)
diff --git
a/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/JasyptProcessor.java
b/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/JasyptProcessor.java
index a0e424098a..1573b56747 100644
---
a/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/JasyptProcessor.java
+++
b/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/JasyptProcessor.java
@@ -30,7 +30,7 @@ import
org.apache.camel.quarkus.component.jasypt.CamelJasyptBuildTimeConfig;
import org.apache.camel.quarkus.component.jasypt.CamelJasyptRecorder;
import
org.apache.camel.quarkus.component.jasypt.CamelJasyptRuntimeConfigBuilder;
import org.apache.camel.quarkus.component.jasypt.JasyptConfigurationCustomizer;
-import org.apache.camel.quarkus.core.deployment.main.spi.CamelMainBuildItem;
+import
org.apache.camel.quarkus.core.deployment.main.spi.CamelMainListenerBuildItem;
import
org.apache.camel.quarkus.core.deployment.spi.RuntimeCamelContextCustomizerBuildItem;
import org.jboss.jandex.ClassInfo;
@@ -55,14 +55,13 @@ class JasyptProcessor {
});
}
- @Record(ExecutionTime.RUNTIME_INIT)
+ @Record(ExecutionTime.STATIC_INIT)
@BuildStep(onlyIf = CamelJasyptEnabled.class)
- void disableCamelMainAutoConfigFromSysEnv(
- CamelMainBuildItem camelMain,
- CamelJasyptRecorder recorder) {
+ CamelMainListenerBuildItem
disableCamelMainAutoConfigFromSysEnv(CamelJasyptRecorder recorder) {
// Avoid camel-main overriding system / environment config values that
were already resolved by SmallRye config.
// Else there's the potential for encrypted property values to be
overridden with their raw ENC(..) form
- recorder.disableCamelMainAutoConfigFromSysEnv(camelMain.getInstance());
+ // Using CamelMainListener for disabling the autoconfig so we rely on
Camel Main listeners to guarantee the order
+ return new
CamelMainListenerBuildItem(recorder.createDisabledCamelMainAutoConfigFromSysEnvMainListener());
}
@Record(ExecutionTime.RUNTIME_INIT)
diff --git
a/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptRecorder.java
b/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptRecorder.java
index 8d8cfc2da1..52f91f4fbd 100644
---
a/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptRecorder.java
+++
b/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptRecorder.java
@@ -24,8 +24,9 @@ import io.smallrye.config.SmallRyeConfig;
import org.apache.camel.CamelContext;
import org.apache.camel.component.jasypt.JasyptPropertiesParser;
import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.main.BaseMainSupport;
import org.apache.camel.main.MainConfigurationProperties;
-import org.apache.camel.quarkus.main.CamelMain;
+import org.apache.camel.main.MainListener;
import org.apache.camel.spi.CamelContextCustomizer;
import org.apache.camel.util.ObjectHelper;
import org.eclipse.microprofile.config.ConfigProvider;
@@ -35,11 +36,45 @@ import org.eclipse.microprofile.config.spi.ConfigSource;
public class CamelJasyptRecorder {
private static final Pattern JASYPT_ENC =
Pattern.compile("ENC\\(\\s*\\S.*\\)");
- public void disableCamelMainAutoConfigFromSysEnv(RuntimeValue<CamelMain>
camelMainRuntimeValue) {
- CamelMain main = camelMainRuntimeValue.getValue();
- MainConfigurationProperties configurationProperties =
main.getMainConfigurationProperties();
-
configurationProperties.setAutoConfigurationSystemPropertiesEnabled(false);
-
configurationProperties.setAutoConfigurationEnvironmentVariablesEnabled(false);
+ public RuntimeValue<MainListener>
createDisabledCamelMainAutoConfigFromSysEnvMainListener() {
+ return new RuntimeValue<>(new MainListener() {
+ @Override
+ public void beforeInitialize(BaseMainSupport main) {
+
+ }
+
+ @Override
+ public void beforeConfigure(BaseMainSupport main) {
+ MainConfigurationProperties configurationProperties =
main.configure();
+
configurationProperties.setAutoConfigurationSystemPropertiesEnabled(false);
+
configurationProperties.setAutoConfigurationEnvironmentVariablesEnabled(false);
+ }
+
+ @Override
+ public void afterConfigure(BaseMainSupport main) {
+
+ }
+
+ @Override
+ public void beforeStart(BaseMainSupport main) {
+
+ }
+
+ @Override
+ public void afterStart(BaseMainSupport main) {
+
+ }
+
+ @Override
+ public void beforeStop(BaseMainSupport main) {
+
+ }
+
+ @Override
+ public void afterStop(BaseMainSupport main) {
+
+ }
+ });
}
public RuntimeValue<CamelContextCustomizer>
createPropertiesComponentCamelContextCustomizer() {
diff --git
a/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptSecureExtensionConfigTest.java
b/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptSecureExtensionConfigTest.java
index 40a33f2de4..8cfdfe40f9 100644
---
a/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptSecureExtensionConfigTest.java
+++
b/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptSecureExtensionConfigTest.java
@@ -20,14 +20,12 @@ import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import io.restassured.RestAssured;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import static org.hamcrest.Matchers.is;
@QuarkusTest
@TestProfile(JasyptSecureExtensionConfigTestProfile.class)
class JasyptSecureExtensionConfigTest {
- @DisabledIfEnvironmentVariable(named = "CI", matches = "true",
disabledReason = "https://github.com/apache/camel-quarkus/issues/5675")
@Test
void secureDirectComponentTimeout() throws InterruptedException {
RestAssured.given()