refactor(config): 重构配置类中的常量定义和方法实现#5583
refactor(config): 重构配置类中的常量定义和方法实现#5583youngzil wants to merge 14 commits intoapolloconfig:masterfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughShared validation/utilities ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apollo-common/src/main/java/com/ctrip/framework/apollo/common/config/RefreshableConfig.java`:
- Around line 145-146: The wrapped logger.warn call in RefreshableConfig (the
logger.warn(...) invocation) is failing Spotless; reformat the statement to
satisfy the project's Java style (or simply run the formatter) by running ./mvnw
spotless:apply before committing so the logger.warn invocation is reformatted
per rules and the Spotless check passes; ensure the modified logger.warn in
RefreshableConfig remains semantically identical (same arguments: value, min,
max, defaultValue).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e1c2cb7d-6d40-414c-8bd1-955dc7502671
📒 Files selected for processing (3)
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/config/BizConfig.javaapollo-common/src/main/java/com/ctrip/framework/apollo/common/config/RefreshableConfig.javaapollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/PortalConfig.java
apollo-common/src/main/java/com/ctrip/framework/apollo/common/config/RefreshableConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/PortalConfig.java`:
- Around line 142-152: getEnvSetProperty() and getEnvironments() need to ignore
empty/blank entries produced by getArrayProperty() (which splits on commas), so
trim each string and skip if it is empty before calling Env.valueOf(...) or
Env.addEnvironment(...); update the loops in getEnvSetProperty and
getEnvironments to do a String trimmed = env.trim(); if (trimmed.isEmpty())
continue; then use trimmed for the Env lookup/add to prevent
IllegalArgumentException on empty strings.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a6093ffe-239d-4760-a884-e63c9147502d
📒 Files selected for processing (2)
apollo-common/src/main/java/com/ctrip/framework/apollo/common/config/RefreshableConfig.javaapollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/PortalConfig.java
🚧 Files skipped from review as they are similar to previous changes (1)
- apollo-common/src/main/java/com/ctrip/framework/apollo/common/config/RefreshableConfig.java
...lo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/PortalConfig.java
Show resolved
Hide resolved
15ec90d to
40528de
Compare
nobodyiam
left a comment
There was a problem hiding this comment.
这次关于环境配置空字符串处理的修复还没有覆盖完整,另外 CHANGES.md 的新增条目位置也需要调整。
请修复以下阻塞项后再更新:
- 补齐
portalSupportedEnvs()对空白/空字符串项的过滤,和getEnvSetProperty()保持一致。 - 增加一个回归测试,覆盖连续逗号/前导逗号这类
apollo.portal.envs配置。
另外还有一个小问题请一并调整:
3. CHANGES.md 里的 #5583 条目请加在当前 change list 的末位,不要加在开头。
What's the purpose of this PR
对 BizConfig、RefreshableConfig、PortalConfig 进行重构,提取常量、合并重复逻辑,提升可读性和可维护性。
Which issue(s) this PR fixes:
Fixes #
Brief changelog
RefreshableConfig
LIST_SEPARATOR、CONFIG_REFRESH_INTERVAL、EMPTY_STRING_ARRAY常量checkInt()方法,统一整型配置校验逻辑BizConfig
INTERVAL_TIME_UNIT常量,简化 5 个返回TimeUnit.SECONDS的方法PortalConfig
getEnvSetProperty()私有方法,合并emailSupportedEnvs()、webHookSupportedEnvs()、publishTipsSupportedEnvs()的重复逻辑DEFAULT_*常量,消除魔法数字Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean testto make sure this pull request doesn't break anything.mvn spotless:applyto format your code.CHANGESlog.Summary by CodeRabbit
Refactor
Chores