Fix bugs, add missing test coverage, and clean up dead code in auto-exchange annotation framework - #4
Draft
juwencheng with Copilot wants to merge 3 commits into
Draft
Fix bugs, add missing test coverage, and clean up dead code in auto-exchange annotation framework#4juwencheng with Copilot wants to merge 3 commits into
juwencheng with Copilot wants to merge 3 commits into
Conversation
Co-authored-by: juwencheng <2663764+juwencheng@users.noreply.github.com>
…ference Co-authored-by: juwencheng <2663764+juwencheng@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review code for automatic exchange rate feature
Fix bugs, add missing test coverage, and clean up dead code in auto-exchange annotation framework
Mar 16, 2026
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.
Code review of the auto-exchange rate annotation across three dimensions: bugs, unit test coverage, and functional completeness.
Bug Fixes
Annotation processor source version mismatch — both processors declared
@SupportedSourceVersion(RELEASE_11)on a Java 17 project, causing 2 test failures via compiler warning.ExchangeManager.init()NPE on null provider response — unlikerefreshRates(),init()had no null guard onfetchData()return. Added consistent null check that retains cache on null response.AutoExchangeContextused wrong map type —HashMap(equals/hashCode) was used to key per-bean appended data. Two distinct instances with equalhashCode/equalswould collide. Changed toIdentityHashMap.ExchangeBeanSerializerModifier.hasAutoExchangeFieldInHierarchy()was a stub — hardcodedreturn truewrapped every bean inAppendingBeanSerializerregardless of whether it had@AutoExchangeField. Replaced with real class hierarchy inspection backed by aConcurrentHashMapcache.Removed deprecated strategy classes with wrong hardcoded values —
AppendApplyExchangeStrategyandInPlaceApplyExchangeStrategyhadBigDecimal.valueOf(2)hardcoded as the exchange rate and"CNY"hardcoded as the target currency. Neither class was used. Removed along withAbstractApplyExchangeStrategyDeprecated.Unit Tests Added
Previously untested paths now covered:
ExchangeManagerTest—init()null handling,refreshRates()null retention, cache updates, rate not foundAutoExchangeContextTest— identity-based key lookup, multiple fields per beanMissingRateThrowExceptionTest—THROW_EXCEPTIONstrategy returns HTTP 500 with structured error viaAutoExchangeExceptionHandler(0% coverage before)MissingRateProtectiveTest—PROTECTIVEstrategy applies configured protective rateMissingRateReturnNullTest—RETURN_NULLstrategy yields null price field@AutoExchangeFieldfield values (should yield price=0, no NPE), and@AutoExchangeBaseCurrencyruntime field resolutionFunctional Completeness
ApplyExchangeModeenum was defined but never referenced anywhere in the framework. Marked@Deprecated. (ICurrencyExchangeServiceandDefaultCurrencyExchangeServicewere already deprecated.)Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.