[kotlin] register service-loaded Jackson modules with useJackson3 - #24876
Open
kdelay wants to merge 1 commit into
Open
[kotlin] register service-loaded Jackson modules with useJackson3#24876kdelay wants to merge 1 commit into
kdelay wants to merge 1 commit into
Conversation
The Jackson 2 branch of Serializer.kt.mustache calls findAndRegisterModules(), so any module published through META-INF/services is picked up. The Jackson 3 branch only called addModule(kotlinModule()), so those modules were dropped. Fixes OpenAPITools#24859
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.
The Jackson 2 branch of
Serializer.kt.mustachecallsfindAndRegisterModules(), so modules published viaMETA-INF/servicesare registered. The Jackson 3 branch added in #24709 only callsaddModule(kotlinModule()), so they are silently dropped.Measured with jackson-databind 3.1.5 and
jackson-databind-nullable:0.2.11, which ships that service file:JsonMapper.builder().build()->{"name":{"present":true,"undefined":false}}.findAndAddModules().build()->{"name":"x"}Adding a module explicitly and by discovery registers it once, so
addModule(kotlinModule())stays.Both jackson3 samples regenerated;
./gradlew compileKotlinon kotlin-jackson3 passes. The new test fails on master.Fixes #24859
/cc @jimschubert @stefankoppier
Summary by cubic
Registers service-loaded Jackson modules when generating Kotlin clients with
useJackson3, fixing #24859.The Jackson 3 branch of
Serializer.ktonly added the Kotlin module, so third-party modules published viaMETA-INF/serviceswere silently dropped. It now callsfindAndAddModules()to match Jackson 2 behavior. Explicit module registration is still deduplicated, soaddModule(kotlinModule())remains.Written for commit 70a8db9. Summary will update on new commits.