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

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


The following commit(s) were added to refs/heads/master by this push:
     new f389a8c  chore(mp-config): don't cache Config instance to prevent 
issues when compiling in native mode with quarkus
f389a8c is described below

commit f389a8c8c346d7cd050870db808cc0a8eb9ae2e1
Author: lburgazzoli <lburgazz...@gmail.com>
AuthorDate: Wed Sep 11 12:57:56 2019 +0200

    chore(mp-config): don't cache Config instance to prevent issues when 
compiling in native mode with quarkus
---
 .../config/CamelMicroProfilePropertiesSource.java  | 49 +++-------------------
 1 file changed, 6 insertions(+), 43 deletions(-)

diff --git 
a/components/camel-microprofile-config/src/main/java/org/apache/camel/component/microprofile/config/CamelMicroProfilePropertiesSource.java
 
b/components/camel-microprofile-config/src/main/java/org/apache/camel/component/microprofile/config/CamelMicroProfilePropertiesSource.java
index cf0a213..58e785a 100644
--- 
a/components/camel-microprofile-config/src/main/java/org/apache/camel/component/microprofile/config/CamelMicroProfilePropertiesSource.java
+++ 
b/components/camel-microprofile-config/src/main/java/org/apache/camel/component/microprofile/config/CamelMicroProfilePropertiesSource.java
@@ -20,7 +20,6 @@ import java.util.Properties;
 import java.util.function.Predicate;
 
 import org.apache.camel.spi.LoadablePropertiesSource;
-import org.apache.camel.support.service.ServiceSupport;
 import org.eclipse.microprofile.config.Config;
 import org.eclipse.microprofile.config.ConfigProvider;
 
@@ -28,17 +27,7 @@ import org.eclipse.microprofile.config.ConfigProvider;
  * The microprofile-config component is used for bridging the Eclipse 
MicroProfile Config with Camels
  * properties component. This allows to use configuration management from 
Eclipse MicroProfile with Camel.
  */
-public class CamelMicroProfilePropertiesSource extends ServiceSupport 
implements LoadablePropertiesSource {
-
-    private Config config;
-
-    public CamelMicroProfilePropertiesSource() {
-    }
-
-    public CamelMicroProfilePropertiesSource(Config config) {
-        this.config = config;
-    }
-
+public class CamelMicroProfilePropertiesSource implements 
LoadablePropertiesSource {
     @Override
     public String getName() {
         return "CamelMicroProfilePropertiesSource";
@@ -46,19 +35,13 @@ public class CamelMicroProfilePropertiesSource extends 
ServiceSupport implements
 
     @Override
     public String getProperty(String name) {
-        if (config == null) {
-            config = ConfigProvider.getConfig();
-        }
-        return config.getOptionalValue(name, String.class).orElse(null);
+        return ConfigProvider.getConfig().getOptionalValue(name, 
String.class).orElse(null);
     }
 
     @Override
     public Properties loadProperties() {
-        if (config == null) {
-            config = ConfigProvider.getConfig();
-        }
-
-        Properties answer = new Properties();
+        final Properties answer = new Properties();
+        final Config config = ConfigProvider.getConfig();
 
         for (String key: config.getPropertyNames()) {
             answer.put(key, config.getValue(key, String.class));
@@ -69,11 +52,8 @@ public class CamelMicroProfilePropertiesSource extends 
ServiceSupport implements
 
     @Override
     public Properties loadProperties(Predicate<String> filter) {
-        if (config == null) {
-            config = ConfigProvider.getConfig();
-        }
-
-        Properties answer = new Properties();
+        final Properties answer = new Properties();
+        final Config config = ConfigProvider.getConfig();
 
         for (String name: config.getPropertyNames()) {
             if (filter.test(name)) {
@@ -83,21 +63,4 @@ public class CamelMicroProfilePropertiesSource extends 
ServiceSupport implements
 
         return answer;
     }
-
-    @Override
-    protected void doInit() throws Exception {
-        if (config == null) {
-            config = ConfigProvider.getConfig();
-        }
-    }
-
-    @Override
-    protected void doStart() throws Exception {
-        // noop
-    }
-
-    @Override
-    protected void doStop() throws Exception {
-        // noop
-    }
 }

Reply via email to