You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2019/08/09 09:10:15 UTC

[GitHub] [servicecomb-java-chassis] HuaiJoe commented on a change in pull request #1234: [SCB-1297]Environment parsing failed to fix

HuaiJoe commented on a change in pull request #1234: [SCB-1297]Environment parsing failed to fix
URL: https://github.com/apache/servicecomb-java-chassis/pull/1234#discussion_r312393019
 
 

 ##########
 File path: foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigurationSpringInitializer.java
 ##########
 @@ -197,11 +197,23 @@ private void getProperties(ConfigurableEnvironment environment, PropertySource<?
     if (propertySource instanceof EnumerablePropertySource) {
       EnumerablePropertySource<?> enumerablePropertySource = (EnumerablePropertySource<?>) propertySource;
       for (String propertyName : enumerablePropertySource.getPropertyNames()) {
-        configFromSpringBoot.put(propertyName, environment.getProperty(propertyName, Object.class));
+        try {
+          configFromSpringBoot.put(propertyName, environment.getProperty(propertyName, Object.class));
+        } catch (Exception e) {
+          if (!getIfIgnoreEnvironment()) {
+            throw new RuntimeException("set up spring property source failed.", e);
+          } else {
+            LOGGER.warn("set up spring property source failed.", e);
+          }
+        }
       }
       return;
     }
 
     LOGGER.debug("a none EnumerablePropertySource is ignored, propertySourceName = [{}]", propertySource.getName());
   }
+
+  private boolean getIfIgnoreEnvironment() {
+    return (Boolean) ConfigUtil.createLocalConfig().getProperty("servicecomb.config.ignoreResolveFailure");
 
 Review comment:
   NPE would be arised if you haven't set any value for  servicecomb.config.ignoreResolveFailure

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services