Skip to content

Commit

Permalink
Use registerKotlinModule function to retain backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Sineaggi committed May 23, 2024
1 parent cc6e9ee commit 9abc712
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,15 @@
package io.temporal.common.converter

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.kotlin.registerKotlinModule

class KotlinObjectMapperFactory {
companion object {
@JvmStatic
fun new(): ObjectMapper {
val mapper = JacksonJsonPayloadConverter.newDefaultObjectMapper()

val km = try {
KotlinModule.Builder()
.build()
} catch (e: NoClassDefFoundError) {
// use deprecated constructor as fallback
@Suppress("deprecation")
KotlinModule()
}
mapper.registerModule(km)
return mapper
return mapper.registerKotlinModule()
}
}
}

0 comments on commit 9abc712

Please sign in to comment.