[HUDI-3869] Improve error handling of loading Hudi conf (#5311)
This commit is contained in:
@@ -99,7 +99,11 @@ public class DFSPropertiesConfiguration {
|
|||||||
if (defaultConfPath.isPresent()) {
|
if (defaultConfPath.isPresent()) {
|
||||||
conf.addPropsFromFile(defaultConfPath.get());
|
conf.addPropsFromFile(defaultConfPath.get());
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
conf.addPropsFromFile(DEFAULT_PATH);
|
conf.addPropsFromFile(DEFAULT_PATH);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warn("Cannot load default config file: " + DEFAULT_PATH, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return conf.getProps();
|
return conf.getProps();
|
||||||
}
|
}
|
||||||
@@ -126,13 +130,17 @@ public class DFSPropertiesConfiguration {
|
|||||||
filePath.toString(),
|
filePath.toString(),
|
||||||
Option.ofNullable(hadoopConfig).orElseGet(Configuration::new)
|
Option.ofNullable(hadoopConfig).orElseGet(Configuration::new)
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (filePath.equals(DEFAULT_PATH) && !fs.exists(filePath)) {
|
if (filePath.equals(DEFAULT_PATH) && !fs.exists(filePath)) {
|
||||||
LOG.warn("Properties file " + filePath + " not found. Ignoring to load props file");
|
LOG.warn("Properties file " + filePath + " not found. Ignoring to load props file");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new HoodieIOException("Cannot check if the properties file exist: " + filePath, ioe);
|
||||||
|
}
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(fs.open(filePath)));
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(fs.open(filePath)))) {
|
||||||
visitedFilePaths.add(filePath.toString());
|
visitedFilePaths.add(filePath.toString());
|
||||||
currentFilePath = filePath;
|
currentFilePath = filePath;
|
||||||
addPropsFromStream(reader);
|
addPropsFromStream(reader);
|
||||||
|
|||||||
Reference in New Issue
Block a user