TubeMQ has been donated to the Apache Software Foundation and renamed to InLong, please visit the new Apache repository: https://github.com/apache/incubator-inlong
MotivationMasterConfig load configs of master.ini, parse and check.If has problems, almost of them throws NullPointerException or IllegalArgumentException.But in some cases, throw NullPointerException probably inappropriate.For example:
code snippet 1:
try {
this.hostName = masterConf.get("hostName").trim();
AddressUtils.validLocalIp(this.hostName);
} catch (Throwable e) {
throw new NullPointerException(new StringBuilder(256)
.append("Illegal hostName value in ").append(SECT_TOKEN_MASTER)
.append(" section!").toString());
}
code snippet 2:
if (!this.startConsumeAuthenticate && this.startConsumeAuthorize) {
throw new NullPointerException(
"startConsumeAuthenticate must set true if startConsumeAuthorize is true!");
}
IllegalArgumentException may more reasonable or use cusutom exception(for example: ConfigException).
In addition, the following exception message not clear enough:
String tmpAuthToken = masterConf.get("confModAuthToken").trim();
if (tmpAuthToken.length() > TServerConstants.CFG_MODAUTHTOKEN_MAX_LENGTH) {
throw new IllegalArgumentException(
"Invalid value: confModAuthToken's value > " + TServerConstants.CFG_MODAUTHTOKEN_MAX_LENGTH);
}
Here is the string length illegal, the more detail exception message should be:
"Invalid value: the length of confModAuthToken's value > " + TServerConstants.CFG_MODAUTHTOKEN_MAX_LENGTH);
Motivation
MasterConfig
load configs ofmaster.ini
, parse and check.If has problems, almost of them throwsNullPointerException
orIllegalArgumentException
.But in some cases, throwNullPointerException
probably inappropriate.For example:IllegalArgumentException
may more reasonable or use cusutom exception(for example:ConfigException
).In addition, the following exception message not clear enough:
Here is the string length illegal, the more detail exception message should be:
(optional) Design
(optional) Example snippet