Skip to content

Commit

Permalink
refactor Jackson code to hardcode buffer-recycler
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored Mar 16, 2024
1 parent e7baef0 commit 9e75505
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.ListBuffer

import com.fasterxml.jackson.core.JsonFactory
import com.fasterxml.jackson.core.JsonFactoryBuilder
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.core.JsonTokenId
import com.fasterxml.jackson.core.Version
import com.fasterxml.jackson.core.json.JsonWriteFeature
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
import com.fasterxml.jackson.core.util.JsonRecyclerPools

import com.fasterxml.jackson.databind.Module.SetupContext
import com.fasterxml.jackson.databind._
Expand Down Expand Up @@ -282,9 +284,10 @@ private[json] object JacksonJson {
}

private[json] case class JacksonJson(jsonConfig: JsonConfig) {
private val mapper = (new ObjectMapper).registerModule(new PlayJsonMapperModule(jsonConfig))

private val jsonFactory = new JsonFactory(mapper)
private val jsonFactory = JsonFactory.builder()
.recyclerPool(JsonRecyclerPools.threadLocalPool())
.build()
private val mapper = new ObjectMapper(jsonFactory).registerModule(new PlayJsonMapperModule(jsonConfig))

private def stringJsonGenerator(out: java.io.StringWriter) =
jsonFactory.createGenerator(out)
Expand Down

0 comments on commit 9e75505

Please sign in to comment.