Browse Source

[Fix-10641] [Common] Fix the hdfs NPE (#10642)

Fix the hdfs NPE (#10642)
3.1.0-release
juzimao 3 years ago committed by GitHub
parent
commit
e0b0f986f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java

14
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java

@ -129,13 +129,16 @@ public class HadoopUtils implements Closeable, StorageOperate {
} }
String defaultFS = configuration.get(Constants.FS_DEFAULT_FS); String defaultFS = configuration.get(Constants.FS_DEFAULT_FS);
if (StringUtils.isBlank(defaultFS)){
defaultFS= PropertyUtils.getString(Constants.FS_DEFAULT_FS);
}
//first get key from core-site.xml hdfs-site.xml ,if null ,then try to get from properties file //first get key from core-site.xml hdfs-site.xml ,if null ,then try to get from properties file
// the default is the local file system // the default is the local file system
if (defaultFS.startsWith("file")) { if (StringUtils.isNotBlank(defaultFS)) {
String defaultFSProp = PropertyUtils.getString(Constants.FS_DEFAULT_FS);
if (StringUtils.isNotBlank(defaultFSProp)) {
Map<String, String> fsRelatedProps = PropertyUtils.getPrefixedProperties("fs."); Map<String, String> fsRelatedProps = PropertyUtils.getPrefixedProperties("fs.");
configuration.set(Constants.FS_DEFAULT_FS, defaultFSProp); configuration.set(Constants.FS_DEFAULT_FS, defaultFS);
fsRelatedProps.forEach((key, value) -> configuration.set(key, value)); fsRelatedProps.forEach((key, value) -> configuration.set(key, value));
} else { } else {
logger.error("property:{} can not to be empty, please set!", Constants.FS_DEFAULT_FS); logger.error("property:{} can not to be empty, please set!", Constants.FS_DEFAULT_FS);
@ -143,7 +146,8 @@ public class HadoopUtils implements Closeable, StorageOperate {
String.format("property: %s can not to be empty, please set!", Constants.FS_DEFAULT_FS) String.format("property: %s can not to be empty, please set!", Constants.FS_DEFAULT_FS)
); );
} }
} else {
if (!defaultFS.startsWith("file")) {
logger.info("get property:{} -> {}, from core-site.xml hdfs-site.xml ", Constants.FS_DEFAULT_FS, defaultFS); logger.info("get property:{} -> {}, from core-site.xml hdfs-site.xml ", Constants.FS_DEFAULT_FS, defaultFS);
} }

Loading…
Cancel
Save