Skip to content

Commit

Permalink
refactor: Resolve code review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun committed Jul 10, 2019
1 parent 927c718 commit 9601e87
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
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

0 comments on commit 9601e87

Please sign in to comment.