Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Resolve code review issues #122

Merged
merged 1 commit into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
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 @@ -82,12 +82,13 @@ public String getConfigAndSignListener(String dataId, String group, long timeout
public void addListener(String dataId, String group, String type, Listener listener) throws NacosException {
Listener listenerAdapter = new DelegatingEventPublishingListener(configService, dataId, group, type, applicationEventPublisher, executor, listener);
addListener(dataId, group, listenerAdapter);
publishEvent(new NacosConfigListenerRegisteredEvent(configService, dataId, group, listenerAdapter, true));
}

@Override
public void addListener(String dataId, String group, Listener listener) throws NacosException {
configService.addListener(dataId, group, listener);
publishEvent(new NacosConfigListenerRegisteredEvent(configService, dataId, group, listener, true));

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void receiveConfigInfo(String config) {
doBind(bean, beanName, dataId, groupId, properties, config, configService);
}
};
try {
try {//
if (configService instanceof EventPublishingConfigService) {
((EventPublishingConfigService) configService).addListener(dataId, groupId, type, listener);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static Properties toProperties(final String dataId, final String group, final St
properties.putAll(configParse.parse(context));
return properties;
} else {
throw new UnsupportedOperationException("Parsing is not yet supported for this type profile");
throw new UnsupportedOperationException("Parsing is not yet supported for this type profile : " + type);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ private static void bindContainer(String prefix, String fieldName, Properties co
String name = StringUtils.isEmpty(prefix) ? s : s.replace(prefix + ".", "");
String value = configProperties.getProperty(s);
if (configProperties.containsKey(fieldName)) {
// for example: list=1,2,3,4,5 will be into here
bindContainer(prefix, fieldName, listToProperties(fieldName, configProperties.getProperty(fieldName)), propertyValues);
}
else if (pattern1.matcher(s).find()) {
Expand All @@ -333,6 +334,13 @@ else if (pattern1.matcher(s).find()) {
}
}

/**
* convert list=1,2,3,4 to list[0]=1, list[1]=2, list[2]=3, list[3]=4
*
* @param fieldName fieldName
* @param content content
* @return {@link Properties}
*/
private static Properties listToProperties(String fieldName, String content) {
String[] splits = content.split(",");
int index = 0;
Expand Down