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/06/29 20:16:16 UTC

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

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


##########
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();
+      } catch (IOException ioe) {
+        throw new HoodieIOException(

Review Comment:
   Thanks for taking a review. I feel like if a customer sets an external hudi config file but somehow Hudi fails to read it, we should terminate the job rather than continuing running it. Because this would be a job with unexpected configs. 



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