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 c8f27cc57f1 CAMEL-20001: camel-core - PropertiesParser should have a hook in a different phase that Spring Boot uses. This ensures that override properties from Camel will take precedence. c8f27cc57f1 is described below commit c8f27cc57f1787f26ea5487bb90eb6b5113d79e5 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sat Oct 21 16:29:46 2023 +0200 CAMEL-20001: camel-core - PropertiesParser should have a hook in a different phase that Spring Boot uses. This ensures that override properties from Camel will take precedence. --- .../camel/component/properties/DefaultPropertiesParser.java | 10 +++++++++- .../apache/camel/component/properties/PropertiesParser.java | 11 +++++++++++ .../modules/ROOT/pages/camel-4x-upgrade-guide-4_2.adoc | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java b/core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java index 0053cc09de9..e74100846fe 100644 --- a/core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java +++ b/core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java @@ -446,6 +446,14 @@ public class DefaultPropertiesParser implements PropertiesParser { } } + if (value == null) { + // custom lookup in spring boot or other runtimes + value = customLookup(key); + if (value != null) { + log.debug("Found property (custom lookup): {} with value: {} to be used.", key, value); + } + } + if (value == null && envMode == PropertiesComponent.ENVIRONMENT_VARIABLES_MODE_FALLBACK) { value = lookupEnvironmentVariable(key); if (value != null) { @@ -461,7 +469,7 @@ public class DefaultPropertiesParser implements PropertiesParser { } } - // parse property may return null (such as when using spring boot and route templates) + // parse property may return null (such as when using route templates) String answer = parseProperty(key, value, properties); if (answer == null) { answer = value; diff --git a/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesParser.java b/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesParser.java index cb9f1cd67f0..7299188fc8f 100644 --- a/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesParser.java +++ b/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesParser.java @@ -50,4 +50,15 @@ public interface PropertiesParser { * @return the value to use */ String parseProperty(String key, String value, PropertiesLookup properties); + + /** + * Allow custom providers to attempt to lookup the property + * + * @param key the key + * @return the value if found or <tt>null</tt> if none found + */ + default String customLookup(String key) { + return null; + } + } diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_2.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_2.adoc index 2546edca1b9..dca28e4a9a3 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_2.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_2.adoc @@ -38,3 +38,9 @@ The Apache Ignite project (v2.15) is not yet Java 21 compatible and therefore `c expected to function correctly if using Java 21. A new release of Apache Ignite is expected that will start to support Java 21. + +=== camel-spring-boot + +The `initialProperties` and `overrideProperties` on Camel `PropertiesComponent` will now +take precedence over Spring Boot properties. This can be used for testing purpose, +to allow overriding properties when using `CamelTestSupport` for unit testing.