From 6af8a230db29f74250dadb78188fc2dae8c5f608 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Fri, 21 Jun 2024 08:41:10 +0900 Subject: [PATCH] .enable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS) --- .../tools/jackson/module/kotlin/Extensions.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/tools/jackson/module/kotlin/Extensions.kt b/src/main/kotlin/tools/jackson/module/kotlin/Extensions.kt index e6e582fc..e6accac3 100644 --- a/src/main/kotlin/tools/jackson/module/kotlin/Extensions.kt +++ b/src/main/kotlin/tools/jackson/module/kotlin/Extensions.kt @@ -4,6 +4,7 @@ import tools.jackson.core.JsonParser import tools.jackson.core.TreeNode import tools.jackson.core.type.TypeReference import tools.jackson.databind.JsonNode +import tools.jackson.databind.MapperFeature import tools.jackson.databind.MappingIterator import tools.jackson.databind.ObjectMapper import tools.jackson.databind.ObjectReader @@ -35,13 +36,21 @@ fun jsonMapper(initializer: JsonMapper.Builder.() -> Unit = {}): JsonMapper { // region: Do not remove the default argument for functions that take a builder as an argument for compatibility. // The default argument can be removed in 2.21 or later. See #775 for the history. -fun jacksonObjectMapper(): ObjectMapper = jsonMapper { addModule(kotlinModule()) } +fun jacksonObjectMapper(): ObjectMapper = jsonMapper { addModule(kotlinModule()) + // [kotlin-module#807] 2024.06.21 : default value changed in Jackson 3, let's keep it enabled until we properly address the issue. + .enable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS) } fun jacksonObjectMapper(initializer: KotlinModule.Builder.() -> Unit = {}): ObjectMapper = - jsonMapper { addModule(kotlinModule(initializer)) } + jsonMapper { addModule(kotlinModule(initializer)) + // [kotlin-module#807] 2024.06.21 : default value changed in Jackson 3, let's keep it enabled until we properly address the issue. + .enable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS) } fun jacksonMapperBuilder(): JsonMapper.Builder = JsonMapper.builder().addModule(kotlinModule()) + // [kotlin-module#807] 2024.06.21 : default value changed in Jackson 3, let's keep it enabled until we properly address the issue. + .enable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS) fun jacksonMapperBuilder(initializer: KotlinModule.Builder.() -> Unit = {}): JsonMapper.Builder = JsonMapper.builder().addModule(kotlinModule(initializer)) + // [kotlin-module#807] 2024.06.21 : default value changed in Jackson 3, let's keep it enabled until we properly address the issue. + .enable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS) // 22-Jul-2019, tatu: Can not be implemented same way as in 2.x, addition via mapper.builder(): // fun ObjectMapper.registerKotlinModule(): ObjectMapper = this.registerModule(kotlinModule())