You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2022/09/28 10:30:47 UTC

[GitHub] [hudi] TengHuo commented on a diff in pull request #5987: [HUDI-4331] Allow loading external config file from class loader

TengHuo commented on code in PR #5987:
URL: https://github.com/apache/hudi/pull/5987#discussion_r982231380


##########
hudi-common/src/main/java/org/apache/hudi/common/config/DFSPropertiesConfiguration.java:
##########
@@ -90,11 +91,24 @@ public DFSPropertiesConfiguration() {
   }
 
   /**
-   * Load global props from hudi-defaults.conf which is under CONF_FILE_DIR_ENV_NAME.
+   * Load global props from hudi-defaults.conf which is under class loader or CONF_FILE_DIR_ENV_NAME.
    * @return Typed Properties
    */
   public static TypedProperties loadGlobalProps() {
     DFSPropertiesConfiguration conf = new DFSPropertiesConfiguration();
+
+    // First try loading the external config file from class loader
+    URL configFile = Thread.currentThread().getContextClassLoader().getResource(DEFAULT_PROPERTIES_FILE);
+    if (configFile != null) {
+      try (BufferedReader br = new BufferedReader(new InputStreamReader(configFile.openStream()))) {
+        conf.addPropsFromStream(br);
+        return conf.getProps();

Review Comment:
   It's a good feature that we can setup a config file from classpath. 
   
   But I think this `return` statement here makes it can't work with `getConfPathFromEnv()` together. Should it be better if we just `conf.addPropsFromStream(br)` here?
   
   Then, if user setup `HUDI_CONF_DIR` in system env, the config file can be loaded as the old behaviour.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org