Skip to content

Commit

Permalink
Handle null string config (#3597)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobegit3hub authored Nov 16, 2023
1 parent dc61777 commit d4f7c82
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private void init() throws ConfigException {
props.setProperty("", "");
}

if (getZkCluster().isEmpty()) {
if (isEmpty(getZkCluster())) {
throw new ConfigException("zookeeper.cluster", "should not be empty");
}

Expand Down Expand Up @@ -343,12 +343,12 @@ private void init() throws ConfigException {
props.setProperty("spark.yarn.jars", "");
}

if (isYarn() && !getSparkYarnJars().isEmpty() && getSparkYarnJars().startsWith("file://")) {
if (isYarn() && !isEmpty(getSparkYarnJars()) && getSparkYarnJars().startsWith("file://")) {
throw new ConfigException("spark.yarn.jars", "should not use local filesystem for yarn mode");
}


if (props.getProperty("spark.home", "").isEmpty()) {
if (isEmpty(props.getProperty("spark.home", ""))) {
if (System.getenv("SPARK_HOME") == null) {
throw new ConfigException("spark.home", "should set config 'spark.home' or environment variable 'SPARK_HOME'");
} else {
Expand Down Expand Up @@ -423,10 +423,10 @@ private void init() throws ConfigException {
props.setProperty("spark.default.conf", "");
}

if (!getSparkDefaultConf().isEmpty()) {
if (!isEmpty(getSparkDefaultConf())) {
String[] defaultSparkConfs = getSparkDefaultConf().split(";");
for (String sparkConfMap : defaultSparkConfs) {
if (!sparkConfMap.isEmpty()) {
if (!isEmpty(sparkConfMap)) {
String[] kv = sparkConfMap.split("=");
if (kv.length < 2) {
throw new ConfigException("spark.default.conf", String.format("error format of %s", sparkConfMap));
Expand All @@ -441,7 +441,7 @@ private void init() throws ConfigException {
props.setProperty("spark.eventLog.dir", "");
}

if (!getSparkEventlogDir().isEmpty() && isYarn()) {
if (!isEmpty(getSparkEventlogDir()) && isYarn()) {
if (getSparkEventlogDir().startsWith("file://")) {
throw new ConfigException("spark.eventLog.dir", "should not use local filesystem for yarn mode");
}
Expand All @@ -460,7 +460,7 @@ private void init() throws ConfigException {
props.setProperty("offline.data.prefix", "file:///tmp/openmldb_offline_storage/");
}

if (getOfflineDataPrefix().isEmpty()) {
if (isEmpty(getOfflineDataPrefix())) {
throw new ConfigException("offline.data.prefix", "should not be null");
} else {
if (isYarn() || isK8s()) {
Expand All @@ -470,11 +470,11 @@ private void init() throws ConfigException {
}
}

if (props.getProperty("batchjob.jar.path", "").isEmpty()) {
if (isEmpty(props.getProperty("batchjob.jar.path", ""))) {
props.setProperty("batchjob.jar.path", BatchJobUtil.findLocalBatchJobJar());
}

if (isYarn() && getHadoopConfDir().isEmpty()) {
if (isYarn() && isEmpty(getHadoopConfDir())) {
if (System.getenv("HADOOP_CONF_DIR") == null) {
throw new ConfigException("hadoop.conf.dir", "should set config 'hadoop.conf.dir' or environment variable 'HADOOP_CONF_DIR'");
} else {
Expand Down Expand Up @@ -532,7 +532,5 @@ public static boolean isEmpty(String s) {
return s == null || s.isEmpty();
}



}

0 comments on commit d4f7c82

Please sign in to comment.