diff --git a/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/context/event/config/EventPublishingConfigService.java b/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/context/event/config/EventPublishingConfigService.java index 7e86d4a6..7354441f 100644 --- a/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/context/event/config/EventPublishingConfigService.java +++ b/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/context/event/config/EventPublishingConfigService.java @@ -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 diff --git a/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/context/properties/config/NacosConfigurationPropertiesBinder.java b/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/context/properties/config/NacosConfigurationPropertiesBinder.java index e5a9e055..22214995 100644 --- a/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/context/properties/config/NacosConfigurationPropertiesBinder.java +++ b/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/context/properties/config/NacosConfigurationPropertiesBinder.java @@ -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 { diff --git a/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/util/ConfigParseUtils.java b/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/util/ConfigParseUtils.java index 9ee202bd..42323e68 100644 --- a/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/util/ConfigParseUtils.java +++ b/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/util/ConfigParseUtils.java @@ -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); } } } diff --git a/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/util/NacosUtils.java b/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/util/NacosUtils.java index 240a5bcc..082f1895 100644 --- a/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/util/NacosUtils.java +++ b/nacos-spring-context/src/main/java/com/alibaba/nacos/spring/util/NacosUtils.java @@ -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()) { @@ -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;