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

encode配置加载 #340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

encode配置加载 #340

wants to merge 1 commit into from

Conversation

ShipinZ
Copy link

@ShipinZ ShipinZ commented Sep 12, 2024

bug描述:

之前配置文件中的encode属性不会被加载到GlobalNacosProperties,导致当加载全局配置时创建的ConfigService的cacheKey不包含encode属性
CacheableEventPublishingNacosServiceFactory.ConfigCreateWorker

        public ConfigService run(Properties properties, ConfigService service) throws NacosException {
           // 当通过全局配置配置创建时,这里的cacheKey不包含encode
            String cacheKey = NacosUtils.identify(properties);
            ConfigService configService = (ConfigService)CacheableEventPublishingNacosServiceFactory.this.configServicesCache.get(cacheKey);
            if (configService == null) {
                if (service == null) {
                    service = NacosFactory.createConfigService(properties);
                }

                configService = new EventPublishingConfigService(service, properties, CacheableEventPublishingNacosServiceFactory.getSingleton().context, CacheableEventPublishingNacosServiceFactory.getSingleton().nacosConfigListenerExecutor);
                CacheableEventPublishingNacosServiceFactory.this.configServicesCache.put(cacheKey, configService);
            }

            return (ConfigService)configService;
        }

但是注解@NacosConfigurationProperties加载的默认配置,又会默认包含encodeUTF-8,所以这导致同一个服务的cacheKey不一致会创建两次ConfigService

修改内容

  1. SubNacosProperties增加encode属性属性
  2. 创建GlobalNacosPropertiesSubNacosProperties时会使用配置文件的里的encode

@CLAassistant
Copy link

CLAassistant commented Sep 12, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants