fix: resolve config refresh failure with spring.config.import on 2025.0.x#4335
Open
wushiyuanmaimob wants to merge 4 commits into
Open
fix: resolve config refresh failure with spring.config.import on 2025.0.x#4335wushiyuanmaimob wants to merge 4 commits into
wushiyuanmaimob wants to merge 4 commits into
Conversation
Verify two defects in NacosPropertySourceRefreshListener: 1. PropertySource name mismatch between ConfigData path (group@dataId) and bootstrap path (dataId,group) 2. File extension hardcoded as 'properties' instead of using actual suffix (yml/json/xml) Related to alibaba#4331 Signed-off-by: wushiyuan <wushiyuanwork@outlook.com>
….0.x Fix two defects in NacosPropertySourceRefreshListener that prevented dynamic config refresh when using spring.config.import=nacos: 1. PropertySource name mismatch: ConfigData path uses 'group@dataId' naming while RefreshListener looked for 'dataId,group'. Now tries both naming conventions. 2. File extension hardcoded: RefreshListener always used 'properties' extension, breaking yml/json/xml configs. Now reads actual suffix from NacosPropertySource. Changes: - Add suffix field to NacosPropertySource to preserve file extension - Update NacosPropertySourceBuilder and NacosConfigDataLoader to pass suffix - Update NacosPropertySourceRefreshListener to handle both naming formats and use actual file extension Fixes alibaba#4331 Signed-off-by: wushiyuan <wushiyuanwork@outlook.com>
The tests were adding plain MapPropertySource to propertySources, but the production code checks for NacosPropertySource type. This caused the refresh logic to never execute, resulting in test failures where values weren't updated. Fixed by: 1. Adding NacosPropertySource wrapper to propertySources instead of inner MapPropertySource 2. Specifying "yml" suffix in NacosPropertySource constructor to match test data Signed-off-by: sywu14 <wushiyuanwork@outlook.com>
58c013c to
05418be
Compare
… tests - YAML parser returns Integer for numeric values, use String.valueOf() - After replace, new NacosPropertySource uses standard dataId,group naming
|
Will the current PR see any further progress? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
Fix two defects in
NacosPropertySourceRefreshListenerthat prevented dynamic config refresh when usingspring.config.import=nacos:on the 2025.0.x branch.Defect 1: PropertySource name mismatch
group@dataIdnaming (NacosConfigDataLoader.java:146)dataId,group(NacosPropertySourceRefreshListener.java:103)target.get(sourceName)always returned null, so refresh never happenedDefect 2: File extension hardcoded
"properties"as file extension (NacosPropertySourceRefreshListener.java:108)NacosItemConfig.suffixbut not propagatedDoes this pull request fix one issue?
Fixes #4331
Describe how you did it
suffixfield toNacosPropertySourceto preserve file extensionNacosPropertySourceBuilderandNacosConfigDataLoaderto pass suffix when creatingNacosPropertySourceNacosPropertySourceRefreshListenerto:dataId,groupand ConfigDatagroup@dataId)NacosPropertySource.getSuffix()instead of hardcoding"properties"Describe how to verify it
spring.config.import=nacos:test-config.ymlRegression tests added in
NacosPropertySourceRefreshListenerTest.Special notes for reviews