jackson 2.18 with max-token-count support (#1556)
* jackson 2.18.1 with max-token-count support * Update Dependencies.scala * remove lock-free buffer-recycler * add non-recycling pool * Update Dependencies.scala
This commit is contained in:
parent
2cd8313bf5
commit
aea4e836e9
5 changed files with 15 additions and 9 deletions
|
|
@ -36,11 +36,10 @@ pekko.serialization.jackson {
|
|||
}
|
||||
|
||||
# Controls the Buffer Recycler Pool implementation used by Jackson.
|
||||
# https://javadoc.io/static/com.fasterxml.jackson.core/jackson-core/2.17.1/com/fasterxml/jackson/core/util/JsonRecyclerPools.html
|
||||
# The default is "thread-local" which is the same as the default in Jackson 2.16.
|
||||
# https://javadoc.io/static/com.fasterxml.jackson.core/jackson-core/2.18.1/com/fasterxml/jackson/core/util/JsonRecyclerPools.html
|
||||
# The default is "thread-local" which is the same as the default in Jackson 2.18.
|
||||
buffer-recycler {
|
||||
# the supported values are "thread-local", "lock-free", "shared-lock-free", "concurrent-deque",
|
||||
# "shared-concurrent-deque", "bounded"
|
||||
# the supported values are "thread-local", "concurrent-deque", "shared-concurrent-deque", "bounded", "non-recycling"
|
||||
pool-instance = "thread-local"
|
||||
# the maximum size of bounded recycler pools - must be >=1 or an IllegalArgumentException will occur
|
||||
# only applies to pool-instance type "bounded"
|
||||
|
|
@ -59,6 +58,8 @@ pekko.serialization.jackson {
|
|||
max-name-length = 50000
|
||||
# max-document-length of -1 means unlimited
|
||||
max-document-length = -1
|
||||
# max-token-count of -1 means unlimited
|
||||
max-token-count = -1
|
||||
}
|
||||
|
||||
write {
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ object JacksonObjectMapperProvider extends ExtensionId[JacksonObjectMapperProvid
|
|||
.maxStringLength(config.getInt("read.max-string-length"))
|
||||
.maxNameLength(config.getInt("read.max-name-length"))
|
||||
.maxDocumentLength(config.getLong("read.max-document-length"))
|
||||
.maxTokenCount(config.getLong("read.max-token-count"))
|
||||
.build()
|
||||
|
||||
val streamWriteConstraints = StreamWriteConstraints.builder()
|
||||
|
|
@ -159,11 +160,10 @@ object JacksonObjectMapperProvider extends ExtensionId[JacksonObjectMapperProvid
|
|||
private def getBufferRecyclerPool(cfg: Config): RecyclerPool[BufferRecycler] = {
|
||||
cfg.getString("buffer-recycler.pool-instance") match {
|
||||
case "thread-local" => JsonRecyclerPools.threadLocalPool()
|
||||
case "lock-free" => JsonRecyclerPools.newLockFreePool()
|
||||
case "shared-lock-free" => JsonRecyclerPools.sharedLockFreePool()
|
||||
case "concurrent-deque" => JsonRecyclerPools.newConcurrentDequePool()
|
||||
case "shared-concurrent-deque" => JsonRecyclerPools.sharedConcurrentDequePool()
|
||||
case "bounded" => JsonRecyclerPools.newBoundedPool(cfg.getInt("buffer-recycler.bounded-pool-size"))
|
||||
case "non-recycling" => JsonRecyclerPools.nonRecyclingPool()
|
||||
case other => throw new IllegalArgumentException(s"Unknown recycler-pool: $other")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,11 +45,13 @@ class JacksonFactorySpec extends TestKit(ActorSystem("JacksonFactorySpec"))
|
|||
val maxStringLen = 1234567
|
||||
val maxDocLen = 123456789L
|
||||
val maxNestingDepth = 5
|
||||
val maxTokenCount = 9876543210L
|
||||
val config = ConfigFactory.parseString(
|
||||
s"""pekko.serialization.jackson.read.max-number-length=$maxNumLen
|
||||
|pekko.serialization.jackson.read.max-string-length=$maxStringLen
|
||||
|pekko.serialization.jackson.read.max-document-length=$maxDocLen
|
||||
|pekko.serialization.jackson.read.max-nesting-depth=$maxNestingDepth
|
||||
|pekko.serialization.jackson.read.max-token-count=$maxTokenCount
|
||||
|""".stripMargin)
|
||||
.withFallback(defaultConfig)
|
||||
val jacksonConfig = JacksonObjectMapperProvider.configForBinding(bindingName, config)
|
||||
|
|
@ -60,6 +62,7 @@ class JacksonFactorySpec extends TestKit(ActorSystem("JacksonFactorySpec"))
|
|||
streamReadConstraints.getMaxStringLength shouldEqual maxStringLen
|
||||
streamReadConstraints.getMaxDocumentLength shouldEqual maxDocLen
|
||||
streamReadConstraints.getMaxNestingDepth shouldEqual maxNestingDepth
|
||||
streamReadConstraints.getMaxTokenCount shouldEqual maxTokenCount
|
||||
}
|
||||
|
||||
"support StreamWriteConstraints" in {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue