You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/12/19 19:07:17 UTC

[GitHub] mikewalch commented on a change in pull request #841: Refactored SiteConfiguration

mikewalch commented on a change in pull request #841: Refactored SiteConfiguration
URL: https://github.com/apache/accumulo/pull/841#discussion_r243038756
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
 ##########
 @@ -82,34 +80,49 @@ public SiteConfiguration(URL accumuloPropsLocation) {
   @SuppressFBWarnings(value = "URLCONNECTION_SSRF_FD",
       justification = "location of props is specified by an admin")
   public SiteConfiguration(URL accumuloPropsLocation, Map<String,String> overrides) {
-    this.overrides = overrides;
+    config = createMap(accumuloPropsLocation, overrides);
+  }
 
-    init();
-    PropertiesConfiguration config = new PropertiesConfiguration();
+  private static ImmutableMap<String,String> createMap(URL accumuloPropsLocation,
+      Map<String,String> overrides) {
+    CompositeConfiguration config = new CompositeConfiguration();
+    config.setThrowExceptionOnMissing(false);
     config.setDelimiterParsingDisabled(true);
+    PropertiesConfiguration propsConfig = new PropertiesConfiguration();
+    propsConfig.setDelimiterParsingDisabled(true);
     if (accumuloPropsLocation != null) {
       try {
-        config.load(accumuloPropsLocation.openStream());
+        propsConfig.load(accumuloPropsLocation.openStream());
       } catch (IOException | ConfigurationException e) {
         throw new IllegalArgumentException(e);
       }
     }
-    internalConfig.addConfiguration(config);
+    config.addConfiguration(propsConfig);
+
+    // Add all properties in config file
+    Map<String,String> result = new HashMap<>();
+    config.getKeys().forEachRemaining(key -> result.put(key, config.getString(key)));
 
-    Map<String,String> temp = StreamSupport
-        .stream(((Iterable<String>) internalConfig::getKeys).spliterator(), false)
-        .collect(Collectors.toMap(Function.identity(), internalConfig::getString));
+    // Add all overrides
+    overrides.keySet().forEach(key -> result.put(key, overrides.get(key)));
 
 Review comment:
   I did this

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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