Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@ private void initCombinedFrom(List<ConfigModel> configModels) {
Configuration conf = ConfigUtil.createConfig(Arrays.asList(model));
String name =
conf.getString(DefinitionConst.qulifiedServiceNameKey, DefinitionConst.defaultMicroserviceName);
if (!StringUtils.isEmpty(name)) {
checkMicroserviceName(name);
combinedFrom.add(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have corresponding test to verify that this is indeed redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like there has no unit tests for this class and no test covers this scene.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combinedFrom will throw NPE when name is null and the logic is different after change when name is empty

}
checkMicroserviceName(name);
combinedFrom.add(name);
}

combinedFrom.remove(microserviceName);
Expand All @@ -108,7 +106,7 @@ private void checkMicroserviceName(String name) {
// the configuration we used
// when resolve placeholder failed
// the result will remains ${var}
if (StringUtils.isEmpty(name) || name.indexOf("${") != -1) {
if (StringUtils.isEmpty(name) || name.contains("${")) {
throw new IllegalArgumentException(String.format(
"MicroserviceName '%s' is invalid. you must configure '%s' or set the placeholder value.",
name,
Expand Down