-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
Search before asking
- I had searched in the issues and found no similar issues.
What happened
In WeChatSender.java, the mkString() method contains a dead-code condition:
private static String mkString(Iterable<String> list) {
if (null == list || StringUtils.isEmpty("|")) {
return null;
}
...
}StringUtils.isEmpty("|") always evaluates to false because "|" is a non-empty string literal. This means the second condition in the || check is dead code. The "|" literal was likely meant to be a variable or parameter representing the separator — possibly from a refactor or copy-paste error.
File: dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java (line ~163)
What you expected to happen
The condition should check a meaningful value. Either:
- The separator should be a method parameter:
mkString(Iterable<String> list, String separator) - Or the dead-code condition should be removed entirely, since the separator
"|"is hardcoded and always valid.
How to reproduce
- Read the source code of
WeChatSender.java, methodmkString()at line 163. - Observe that
StringUtils.isEmpty("|")is alwaysfalse— this is verifiable by running any Java expression evaluator. - The dead branch
return nulldue to the second condition can never be reached.
Anything else
This is a static code analysis bug. It does not cause a runtime crash, but it indicates a logic defect: the separator was likely intended to be configurable or passed as a parameter. The method only works correctly by accident because the hardcoded "|" is non-empty.
Version
dev
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct