Fix Feign JSON converter to use application JsonMapper modules - #1399
Open
arimu1 wants to merge 1 commit into
Open
Fix Feign JSON converter to use application JsonMapper modules#1399arimu1 wants to merge 1 commit into
arimu1 wants to merge 1 commit into
Conversation
registerDefaults() may install a classpath-default Jackson mapper that does not include JacksonModule beans (e.g. JavaxMoneyModule). Wire the application JsonMapper into FeignHttpMessageConverters after Boot ClientHttpMessageConvertersCustomizers so Feign deserializes the same types as MVC. Fixes spring-cloudgh-1376 Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
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.
Motivation and Context
Fixes #1376 — Feign could not deserialize types that need Jackson modules registered as beans (e.g.
JavaxMoneyModule/MonetaryAmount), while the same app's@RestControllerworked.FeignHttpMessageConverterscalledregisterDefaults(), which can install a classpath-defaultJacksonJsonHttpMessageConverterwhose mapper does not include applicationJacksonModulebeans. Boot'sClientHttpMessageConvertersCustomizerpath is not always enough for Feign child contexts; the proven workaround was a lateHttpMessageConverterCustomizerthat reinstalls a converter backed by the applicationJsonMapper.How has this been tested?
FeignHttpMessageConvertersTests(concurrent init + application JsonMapper / module coverage) — 2/2 (Temurin 21)./mvnw -pl spring-cloud-openfeign-core test -Dtest=FeignHttpMessageConvertersTests -PspringTypes of changes
Checklist:
Changes
ClientHttpMessageConvertersCustomizers, apply the applicationJsonMapper(when present) viawithJsonConverter, so Feign uses the same modules as MVC.JsonMapperviaBeanFactorywithout requiring Jackson on the configuration class classpath.JacksonModule(stand-in for money types).