Skip to content

Commit

Permalink
Fix performance issues in jackson-module-scala and json4s with jackso…
Browse files Browse the repository at this point in the history
  • Loading branch information
Andriy Plokhotnyuk committed Mar 13, 2024
1 parent 2215c20 commit 537bed2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.util.concurrent.ConcurrentHashMap
import com.fasterxml.jackson.annotation.JsonInclude.Include
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.core.json.JsonWriteFeature
import com.fasterxml.jackson.core.util.{DefaultIndenter, DefaultPrettyPrinter}
import com.fasterxml.jackson.core.util.{DefaultIndenter, DefaultPrettyPrinter, JsonRecyclerPools}
import com.fasterxml.jackson.core._
import com.fasterxml.jackson.databind._
import com.fasterxml.jackson.databind.jsontype.NamedType
Expand All @@ -29,6 +29,7 @@ object JacksonSerDesers {
.configure(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER, true)
.configure(StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION, true)
.streamReadConstraints(StreamReadConstraints.builder().maxNumberLength(Int.MaxValue).build()) /* WARNING: It is an unsafe option for open systems */
.recyclerPool(JsonRecyclerPools.threadLocalPool())
.build()
new ObjectMapper(jsonFactory) with ClassTagExtensions {
addMixIn(classOf[GeoJSON.GeoJSON], classOf[MixIn])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ object Json4sJacksonMappers {
.configure(JsonWriteFeature.ESCAPE_NON_ASCII, escapeNonAscii)
.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER, true)
.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER, true)
.recyclerPool(JsonRecyclerPools.threadLocalPool())
.build()
new ObjectMapper(jsonFactory)
.registerModule(new Json4sScalaModule)
Expand Down

0 comments on commit 537bed2

Please sign in to comment.