Fix Feign JSON converter to use application JsonMapper modules - #1399
Fix Feign JSON converter to use application JsonMapper modules#1399arimu1 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>
|
See my comment here #1376 (comment) |
|
@ryanjbaxter Thanks for the pointer to #1306 / Spring Cloud 2025.0.1 (OpenFeign 5.0.1). I'll treat this as likely already fixed on the If it still fails on 2025.0.2, this PR's explicit application- |
|
I am going to close this for now and we can reopen it if necessary |
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).