-
Notifications
You must be signed in to change notification settings - Fork 12k
Open
Labels
Description
Before Creating the Enhancement Request
- I have confirmed that this should be classified as an enhancement rather than a bug/feature.
Summary
When initializing ProxyConfig, if localServeAddr is mistakenly set to a few empty characters by the user, such as localServerAddr=" ", it will cause an exception 'get local serve ip failed' to be thrown. The real reason is simply a configuration error, which can mislead troubleshooting.
Motivation
enhance config check
Describe the Solution You'd Like
Uniformly use the isBlanck method, which supports checking for null and a length of 0, and can completely replace the isEmpty method.
Describe Alternatives You've Considered
A clearer way to write:
if (StringUtils.isBlank(localServeAddr)) {
this.localServeAddr = NetworkUtil.getLocalAddress();
if (StringUtils.isBlank(localServeAddr)) {
throw new ProxyException(ProxyExceptionCode.INTERNAL_SERVER_ERROR,
"failed to get local IP address");
}
}Additional Context
detail:
- config:
localServeAddr= # has several blank char
or
localServeAddr=\t- config init logic
private String localServeAddr = " "; // from config file
if (StringUtils.isEmpty(localServeAddr)) { // false! " ".length() > 0 and != null
// skip, failed to retrieve the local address
}
if (StringUtils.isBlank(localServeAddr)) { // true!
throw new ProxyException(...); // Throws an exception
}This may lead the user to mistakenly believe there is a network issue.