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 2021/02/06 16:47:41 UTC

[camel] branch master updated (0ae29c1 -> eb41524)

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

davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 0ae29c1  Upgrade checkstyle
     new 115e95a  CAMEL-16160: camel-main - JVM system properties should override application.properties
     new d8659ef  Fix java routes loader compute name to deal with location having scheme
     new 7c9eeab  CAMEL-16160: camel-main - JVM system properties should override application.properties
     new eb41524  Polished

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../language/joor/JoorRoutesBuilderLoader.java     |  9 ++-
 .../MainConfigurationPropertiesConfigurer.java     |  6 ++
 .../camel-main-configuration-metadata.json         |  1 +
 core/camel-main/src/main/docs/main.adoc            |  1 +
 .../org/apache/camel/main/BaseMainSupport.java     | 67 ++++++++++++++++++++--
 .../apache/camel/main/DefaultRoutesCollector.java  | 12 ++--
 .../camel/main/MainConfigurationProperties.java    | 33 +++++++++++
 .../java/org/apache/camel/main/MainHelper.java     | 25 ++++++++
 8 files changed, 139 insertions(+), 15 deletions(-)


[camel] 04/04: Polished

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit eb415246efb97e569a7b46ac41a77bc0e0de8ebf
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 6 17:46:52 2021 +0100

    Polished
---
 .../java/org/apache/camel/main/DefaultRoutesCollector.java   | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java
index 198697f..648bd5c 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ExtendedCamelContext;
@@ -127,7 +126,6 @@ public class DefaultRoutesCollector implements RoutesCollector {
         }
 
         StopWatch watch = new StopWatch();
-        AtomicInteger count = new AtomicInteger();
 
         if (ObjectHelper.equal("false", includePattern)) {
             return answer;
@@ -147,18 +145,16 @@ public class DefaultRoutesCollector implements RoutesCollector {
                     }
 
                     log.debug("Found {} route builder from location: {}", builders.size(), include);
-                    for (RoutesBuilder builder : builders) {
-                        answer.add(builder);
-                        count.incrementAndGet();
-                    }
+                    answer.addAll(builders);
                 }
             } catch (FileNotFoundException e) {
                 log.debug("No RoutesBuilder found in {}. Skipping detection.", include);
             } catch (Exception e) {
                 throw RuntimeCamelException.wrapRuntimeException(e);
             }
-            if (count.get() > 0) {
-                log.info("Loaded {} ({} millis) additional RoutesBuilder from: {}, pattern: {}", count, watch.taken(), include,
+            if (answer.size() > 0) {
+                log.info("Loaded {} ({} millis) additional RoutesBuilder from: {}, pattern: {}", answer.size(), watch.taken(),
+                        include,
                         includePattern);
             } else {
                 log.debug("No additional RoutesBuilder discovered from: {}", includePattern);


[camel] 01/04: CAMEL-16160: camel-main - JVM system properties should override application.properties

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 115e95a02c57f899d75d82a6518566a64bd54281
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 6 17:01:02 2021 +0100

    CAMEL-16160: camel-main - JVM system properties should override application.properties
---
 .../MainConfigurationPropertiesConfigurer.java     |  6 +++
 .../camel-main-configuration-metadata.json         |  1 +
 core/camel-main/src/main/docs/main.adoc            |  1 +
 .../org/apache/camel/main/BaseMainSupport.java     | 59 +++++++++++++++++++---
 .../camel/main/MainConfigurationProperties.java    | 33 ++++++++++++
 .../java/org/apache/camel/main/MainHelper.java     | 21 ++++++++
 6 files changed, 115 insertions(+), 6 deletions(-)

diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java
index 98f902c..797ed98 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java
@@ -31,6 +31,8 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp
         case "AutoConfigurationFailFast": target.setAutoConfigurationFailFast(property(camelContext, boolean.class, value)); return true;
         case "autoconfigurationlogsummary":
         case "AutoConfigurationLogSummary": target.setAutoConfigurationLogSummary(property(camelContext, boolean.class, value)); return true;
+        case "autoconfigurationsystempropertiesenabled":
+        case "AutoConfigurationSystemPropertiesEnabled": target.setAutoConfigurationSystemPropertiesEnabled(property(camelContext, boolean.class, value)); return true;
         case "autostartup":
         case "AutoStartup": target.setAutoStartup(property(camelContext, boolean.class, value)); return true;
         case "autowiredenabled":
@@ -210,6 +212,8 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp
         case "AutoConfigurationFailFast": return boolean.class;
         case "autoconfigurationlogsummary":
         case "AutoConfigurationLogSummary": return boolean.class;
+        case "autoconfigurationsystempropertiesenabled":
+        case "AutoConfigurationSystemPropertiesEnabled": return boolean.class;
         case "autostartup":
         case "AutoStartup": return boolean.class;
         case "autowiredenabled":
@@ -390,6 +394,8 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp
         case "AutoConfigurationFailFast": return target.isAutoConfigurationFailFast();
         case "autoconfigurationlogsummary":
         case "AutoConfigurationLogSummary": return target.isAutoConfigurationLogSummary();
+        case "autoconfigurationsystempropertiesenabled":
+        case "AutoConfigurationSystemPropertiesEnabled": return target.isAutoConfigurationSystemPropertiesEnabled();
         case "autostartup":
         case "AutoStartup": return target.isAutoStartup();
         case "autowiredenabled":
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 9e75fce..bab09f1 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -15,6 +15,7 @@
     { "name": "camel.main.autoConfigurationEnvironmentVariablesEnabled", "description": "Whether auto configuration should include OS environment variables as well. When enabled this allows to overrule any configuration using an OS environment variable. For example to set a shutdown timeout of 5 seconds: CAMEL_MAIN_SHUTDOWNTIMEOUT=5. This option is default enabled.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue [...]
     { "name": "camel.main.autoConfigurationFailFast", "description": "Whether auto configuration should fail fast when configuring one ore more properties fails for whatever reason such as a invalid property name, etc. This option is default enabled.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
     { "name": "camel.main.autoConfigurationLogSummary", "description": "Whether auto configuration should log a summary with the configured properties. This option is default enabled.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
+    { "name": "camel.main.autoConfigurationSystemPropertiesEnabled", "description": "Whether auto configuration should include JVM system properties as well. When enabled this allows to overrule any configuration using a JVM system property. For example to set a shutdown timeout of 5 seconds: -D camel.main.shutdown-timeout=5. Note that JVM system properties take precedence over OS environment variables. This option is default enabled.", "sourceType": "org.apache.camel.main.MainConfigurat [...]
     { "name": "camel.main.autoStartup", "description": "Sets whether the object should automatically start when Camel starts. Important: Currently only routes can be disabled, as CamelContext's are always started. Note: When setting auto startup false on CamelContext then that takes precedence and no routes are started. You would need to start CamelContext explicit using the org.apache.camel.CamelContext.start() method, to start the context, and then you would need to start the routes ma [...]
     { "name": "camel.main.autowiredEnabled", "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. Default is true.", "sourceType": "org.apache.camel.main.DefaultConfiguration [...]
     { "name": "camel.main.backlogTracing", "description": "Sets whether backlog tracing is enabled or not. Default is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean" },
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index bff9c2c..176b620 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -27,6 +27,7 @@ The following table lists all the options:
 | *camel.main.autoConfiguration{zwsp}EnvironmentVariablesEnabled* | Whether auto configuration should include OS environment variables as well. When enabled this allows to overrule any configuration using an OS environment variable. For example to set a shutdown timeout of 5 seconds: CAMEL_MAIN_SHUTDOWNTIMEOUT=5. This option is default enabled. | true | boolean
 | *camel.main.autoConfiguration{zwsp}FailFast* | Whether auto configuration should fail fast when configuring one ore more properties fails for whatever reason such as a invalid property name, etc. This option is default enabled. | true | boolean
 | *camel.main.autoConfiguration{zwsp}LogSummary* | Whether auto configuration should log a summary with the configured properties. This option is default enabled. | true | boolean
+| *camel.main.autoConfiguration{zwsp}SystemPropertiesEnabled* | Whether auto configuration should include JVM system properties as well. When enabled this allows to overrule any configuration using a JVM system property. For example to set a shutdown timeout of 5 seconds: -D camel.main.shutdown-timeout=5. Note that JVM system properties take precedence over OS environment variables. This option is default enabled. | true | boolean
 | *camel.main.autoStartup* | Sets whether the object should automatically start when Camel starts. Important: Currently only routes can be disabled, as CamelContext's are always started. Note: When setting auto startup false on CamelContext then that takes precedence and no routes are started. You would need to start CamelContext explicit using the org.apache.camel.CamelContext.start() method, to start the context, and then you would need to start the routes manually using CamelContext.g [...]
 | *camel.main.autowiredEnabled* | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. Default is true. | true | boolean
 | *camel.main.backlogTracing* | Sets whether backlog tracing is enabled or not. Default is false. |  | boolean
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 32faf50..1c16fa9 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
@@ -67,12 +67,7 @@ import org.apache.camel.util.StringHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.camel.main.MainHelper.computeProperties;
-import static org.apache.camel.main.MainHelper.loadEnvironmentVariablesAsProperties;
-import static org.apache.camel.main.MainHelper.lookupPropertyFromSysOrEnv;
-import static org.apache.camel.main.MainHelper.optionKey;
-import static org.apache.camel.main.MainHelper.setPropertiesOnTarget;
-import static org.apache.camel.main.MainHelper.validateOptionAndValue;
+import static org.apache.camel.main.MainHelper.*;
 import static org.apache.camel.support.ObjectHelper.invokeMethod;
 import static org.apache.camel.util.ReflectionHelper.findMethod;
 import static org.apache.camel.util.StringHelper.matches;
@@ -568,9 +563,27 @@ public abstract class BaseMainSupport extends BaseService {
                 }
             }
         }
+        // load properties from JVM (override existing)
+        Properties propJVM = null;
+        if (mainConfigurationProperties.isAutoConfigurationSystemPropertiesEnabled()) {
+            propJVM = loadJvmSystemPropertiesAsProperties(new String[] { "camel.main." });
+            if (!propJVM.isEmpty()) {
+                prop.putAll(propJVM);
+                LOG.debug("Properties from JVM system properties:");
+                for (String key : propJVM.stringPropertyNames()) {
+                    LOG.debug("    {}={}", key, propJVM.getProperty(key));
+                }
+            }
+        }
 
         // special for fail-fast as we need to know this early before we set all the other options
         Object failFast = propENV != null ? propENV.remove("camel.main.autoconfigurationfailfast") : null;
+        if (propJVM != null) {
+            Object val = propJVM.remove("camel.main.autoconfigurationfailfast");
+            if (val != null) {
+                failFast = val;
+            }
+        }
         if (failFast != null) {
             mainConfigurationProperties
                     .setAutoConfigurationFailFast(CamelContextHelper.parseBoolean(camelContext, failFast.toString()));
@@ -642,6 +655,17 @@ public abstract class BaseMainSupport extends BaseService {
                 }
             }
         }
+        // load properties from JVM (override existing)
+        if (mainConfigurationProperties.isAutoConfigurationSystemPropertiesEnabled()) {
+            Properties propJVM = loadJvmSystemPropertiesAsProperties(new String[] { "camel.component.properties." });
+            if (!propJVM.isEmpty()) {
+                prop.putAll(propJVM);
+                LOG.debug("Properties from JVM system properties:");
+                for (String key : propJVM.stringPropertyNames()) {
+                    LOG.debug("    {}={}", key, propJVM.getProperty(key));
+                }
+            }
+        }
 
         Map<String, Object> contextProperties = new LinkedHashMap<>();
         Map<String, Object> hystrixProperties = new LinkedHashMap<>();
@@ -1007,6 +1031,13 @@ public abstract class BaseMainSupport extends BaseService {
                 prop.putAll(propENV);
             }
         }
+        // load properties from JVM (override existing)
+        if (mainConfigurationProperties.isAutoConfigurationSystemPropertiesEnabled()) {
+            Properties propJVM = loadJvmSystemPropertiesAsProperties(new String[] { "camel.component.properties." });
+            if (!propJVM.isEmpty()) {
+                prop.putAll(propJVM);
+            }
+        }
 
         Map<String, Object> properties = new LinkedHashMap<>();
 
@@ -1045,6 +1076,7 @@ public abstract class BaseMainSupport extends BaseService {
         // load properties from ENV (override existing)
         if (mainConfigurationProperties.isAutoConfigurationEnvironmentVariablesEnabled()) {
             Properties propENV = loadEnvironmentVariablesAsProperties(new String[] { "camel.main." });
+            // ENV variables cannot use dash so replace with dot
             propENV.remove(INITIAL_PROPERTIES_LOCATION.replace('-', '.'));
             propENV.remove(OVERRIDE_PROPERTIES_LOCATION.replace('-', '.'));
             propENV.remove(PROPERTY_PLACEHOLDER_LOCATION.replace('-', '.'));
@@ -1052,6 +1084,13 @@ public abstract class BaseMainSupport extends BaseService {
                 prop.putAll(propENV);
             }
         }
+        // load properties from JVM (override existing)
+        if (mainConfigurationProperties.isAutoConfigurationSystemPropertiesEnabled()) {
+            Properties propJVM = loadJvmSystemPropertiesAsProperties(new String[] { "camel.main." });
+            if (!propJVM.isEmpty()) {
+                prop.putAll(propJVM);
+            }
+        }
 
         Map<String, Object> properties = new LinkedHashMap<>();
 
@@ -1117,6 +1156,14 @@ public abstract class BaseMainSupport extends BaseService {
                 prop.putAll(propENV);
             }
         }
+        // load properties from JVM (override existing)
+        if (mainConfigurationProperties.isAutoConfigurationSystemPropertiesEnabled()) {
+            Properties propJVM = loadJvmSystemPropertiesAsProperties(
+                    new String[] { "camel.component.", "camel.dataformat.", "camel.language." });
+            if (!propJVM.isEmpty()) {
+                prop.putAll(propJVM);
+            }
+        }
 
         Map<PropertyOptionKey, Map<String, Object>> properties = new LinkedHashMap<>();
 
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
index b883d62..74b00d6 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
@@ -34,6 +34,7 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
 
     private boolean autoConfigurationEnabled = true;
     private boolean autoConfigurationEnvironmentVariablesEnabled = true;
+    private boolean autoConfigurationSystemPropertiesEnabled = true;
     private boolean autoConfigurationFailFast = true;
     private boolean autoConfigurationLogSummary = true;
     private int durationHitExitCode;
@@ -206,6 +207,23 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
         this.autoConfigurationEnvironmentVariablesEnabled = autoConfigurationEnvironmentVariablesEnabled;
     }
 
+    public boolean isAutoConfigurationSystemPropertiesEnabled() {
+        return autoConfigurationSystemPropertiesEnabled;
+    }
+
+    /**
+     * Whether auto configuration should include JVM system properties as well. When enabled this allows to overrule any
+     * configuration using a JVM system property. For example to set a shutdown timeout of 5 seconds: -D
+     * camel.main.shutdown-timeout=5.
+     * <p/>
+     * Note that JVM system properties take precedence over OS environment variables.
+     * <p/>
+     * This option is default enabled.
+     */
+    public void setAutoConfigurationSystemPropertiesEnabled(boolean autoConfigurationSystemPropertiesEnabled) {
+        this.autoConfigurationSystemPropertiesEnabled = autoConfigurationSystemPropertiesEnabled;
+    }
+
     public boolean isAutoConfigurationFailFast() {
         return autoConfigurationFailFast;
     }
@@ -410,6 +428,21 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
     }
 
     /**
+     * Whether auto configuration should include JVM system properties as well. When enabled this allows to overrule any
+     * configuration using a JVM system property. For example to set a shutdown timeout of 5 seconds: -D
+     * camel.main.shutdown-timeout=5.
+     * <p/>
+     * Note that JVM system properties take precedence over OS environment variables.
+     * <p/>
+     * This option is default enabled.
+     */
+    public MainConfigurationProperties withAutoConfigurationSystemPropertiesEnabled(
+            boolean autoConfigurationSystemPropertiesEnabled) {
+        this.autoConfigurationSystemPropertiesEnabled = autoConfigurationSystemPropertiesEnabled;
+        return this;
+    }
+
+    /**
      * Whether auto configuration should fail fast when configuring one ore more properties fails for whatever reason
      * such as a invalid property name, etc.
      * <p/>
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
index 7049fe9..c48cad0 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
@@ -77,6 +77,27 @@ public final class MainHelper {
         return answer;
     }
 
+    public static Properties loadJvmSystemPropertiesAsProperties(String[] prefixes) {
+        Properties answer = new OrderedProperties();
+        if (prefixes == null || prefixes.length == 0) {
+            return answer;
+        }
+
+        for (String prefix : prefixes) {
+            final String pk = prefix.toUpperCase(Locale.US).replaceAll("[^\\w]", "-");
+            final String pk2 = pk.replace('-', '.');
+            System.getProperties().forEach((k, v) -> {
+                String key = k.toString().toUpperCase(Locale.US);
+                if (key.startsWith(pk) || key.startsWith(pk2)) {
+                    key = key.toLowerCase(Locale.ENGLISH).replace('_', '.');
+                    answer.put(key, v);
+                }
+            });
+        }
+
+        return answer;
+    }
+
     public static String optionKey(String key) {
         // as we ignore case for property names we should use keys in same case and without dashes
         key = StringHelper.dashToCamelCase(key);


[camel] 03/04: CAMEL-16160: camel-main - JVM system properties should override application.properties

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 7c9eeab5013976fa0c7bf8a84cc249a82022e677
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 6 17:37:07 2021 +0100

    CAMEL-16160: camel-main - JVM system properties should override application.properties
---
 .../src/main/java/org/apache/camel/main/BaseMainSupport.java   |  8 ++++++++
 .../src/main/java/org/apache/camel/main/MainHelper.java        | 10 +++++++---
 2 files changed, 15 insertions(+), 3 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 1c16fa9..ab1ac48 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
@@ -1076,6 +1076,7 @@ public abstract class BaseMainSupport extends BaseService {
         // load properties from ENV (override existing)
         if (mainConfigurationProperties.isAutoConfigurationEnvironmentVariablesEnabled()) {
             Properties propENV = loadEnvironmentVariablesAsProperties(new String[] { "camel.main." });
+            // special handling of these so remove them
             // ENV variables cannot use dash so replace with dot
             propENV.remove(INITIAL_PROPERTIES_LOCATION.replace('-', '.'));
             propENV.remove(OVERRIDE_PROPERTIES_LOCATION.replace('-', '.'));
@@ -1087,6 +1088,13 @@ public abstract class BaseMainSupport extends BaseService {
         // load properties from JVM (override existing)
         if (mainConfigurationProperties.isAutoConfigurationSystemPropertiesEnabled()) {
             Properties propJVM = loadJvmSystemPropertiesAsProperties(new String[] { "camel.main." });
+            // special handling of these so remove them
+            propJVM.remove(INITIAL_PROPERTIES_LOCATION);
+            propJVM.remove(StringHelper.dashToCamelCase(INITIAL_PROPERTIES_LOCATION));
+            propJVM.remove(OVERRIDE_PROPERTIES_LOCATION);
+            propJVM.remove(StringHelper.dashToCamelCase(OVERRIDE_PROPERTIES_LOCATION));
+            propJVM.remove(PROPERTY_PLACEHOLDER_LOCATION);
+            propJVM.remove(StringHelper.dashToCamelCase(PROPERTY_PLACEHOLDER_LOCATION));
             if (!propJVM.isEmpty()) {
                 prop.putAll(propJVM);
             }
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
index c48cad0..8412e8d 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
@@ -86,11 +86,15 @@ public final class MainHelper {
         for (String prefix : prefixes) {
             final String pk = prefix.toUpperCase(Locale.US).replaceAll("[^\\w]", "-");
             final String pk2 = pk.replace('-', '.');
+            Map<String, String> env = System.getenv();
             System.getProperties().forEach((k, v) -> {
                 String key = k.toString().toUpperCase(Locale.US);
-                if (key.startsWith(pk) || key.startsWith(pk2)) {
-                    key = key.toLowerCase(Locale.ENGLISH).replace('_', '.');
-                    answer.put(key, v);
+                if (!env.containsKey(key)) {
+                    // skip keys that are already from ENV so we don't process it twice
+                    // as we only want to do this for JVM system properties
+                    if (key.startsWith(pk) || key.startsWith(pk2)) {
+                        answer.put(k.toString(), v);
+                    }
                 }
             });
         }


[camel] 02/04: Fix java routes loader compute name to deal with location having scheme

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit d8659efd1d4b4f6b5ad79a2c6fa782363cbdb3c9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 6 17:07:35 2021 +0100

    Fix java routes loader compute name to deal with location having scheme
---
 .../org/apache/camel/language/joor/JoorRoutesBuilderLoader.java  | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/components/camel-joor/src/main/java/org/apache/camel/language/joor/JoorRoutesBuilderLoader.java b/components/camel-joor/src/main/java/org/apache/camel/language/joor/JoorRoutesBuilderLoader.java
index 131000f..3b824c0 100644
--- a/components/camel-joor/src/main/java/org/apache/camel/language/joor/JoorRoutesBuilderLoader.java
+++ b/components/camel-joor/src/main/java/org/apache/camel/language/joor/JoorRoutesBuilderLoader.java
@@ -27,6 +27,7 @@ import org.apache.camel.RoutesBuilder;
 import org.apache.camel.spi.Resource;
 import org.apache.camel.spi.RoutesBuilderLoader;
 import org.apache.camel.spi.annotations.JdkService;
+import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.IOHelper;
 import org.joor.Reflect;
@@ -68,7 +69,13 @@ public class JoorRoutesBuilderLoader implements RoutesBuilderLoader, CamelContex
     }
 
     private String determineName(Resource resource, String content) {
-        final String name = FileUtil.onlyName(resource.getLocation(), true);
+        String loc = resource.getLocation();
+        // strip scheme to compute the name
+        String scheme = ResourceHelper.getScheme(loc);
+        if (scheme != null) {
+            loc = loc.substring(scheme.length());
+        }
+        final String name = FileUtil.onlyName(loc, true);
         final Matcher matcher = PACKAGE_PATTERN.matcher(content);
 
         return matcher.find()