This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new aea4e836e9 jackson 2.18 with max-token-count support (#1556)
aea4e836e9 is described below

commit aea4e836e9dcb792e9b0295b8c1c083cb5f59199
Author: PJ Fanning <[email protected]>
AuthorDate: Sat Dec 28 14:01:10 2024 +0100

    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
---
 .scala-steward.conf                                              | 3 ++-
 project/Dependencies.scala                                       | 5 +++--
 serialization-jackson/src/main/resources/reference.conf          | 9 +++++----
 .../serialization/jackson/JacksonObjectMapperProvider.scala      | 4 ++--
 .../apache/pekko/serialization/jackson/JacksonFactorySpec.scala  | 3 +++
 5 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/.scala-steward.conf b/.scala-steward.conf
index 37d642f9ee..5e331c2943 100644
--- a/.scala-steward.conf
+++ b/.scala-steward.conf
@@ -1,5 +1,6 @@
 updates.pin = [
-  { groupId = "com.fasterxml.jackson.core", version = "2.17." }
+  # Jackson upgrades can be complicated to coordinate across modules - it is 
better to upgrade manually
+  { groupId = "com.fasterxml.jackson.core", version = "2.18." }
   # Pin logback to v1.3.x because v1.4.x needs JDK11
   { groupId = "ch.qos.logback", version="1.3." }
   # Pin sbt-paradox to v0.9.x because 0.10.x needs JDK 11
diff --git a/project/Dependencies.scala b/project/Dependencies.scala
index 56060cc136..f87a309dbd 100644
--- a/project/Dependencies.scala
+++ b/project/Dependencies.scala
@@ -38,7 +38,7 @@ object Dependencies {
   val nettyVersion = "4.1.116.Final"
   val logbackVersion = "1.3.14"
 
-  val jacksonCoreVersion = "2.17.3"
+  val jacksonCoreVersion = "2.18.2"
   val jacksonDatabindVersion = jacksonCoreVersion
 
   val scala212Version = "2.12.20"
@@ -106,7 +106,8 @@ object Dependencies {
     val jacksonDatabind = "com.fasterxml.jackson.core" % "jackson-databind" % 
jacksonDatabindVersion
     val jacksonJdk8 = "com.fasterxml.jackson.datatype" % 
"jackson-datatype-jdk8" % jacksonCoreVersion
     val jacksonJsr310 = "com.fasterxml.jackson.datatype" % 
"jackson-datatype-jsr310" % jacksonCoreVersion
-    val jacksonScala = "com.fasterxml.jackson.module" %% 
"jackson-module-scala" % jacksonCoreVersion
+    val jacksonScala = ("com.fasterxml.jackson.module" %% 
"jackson-module-scala" % jacksonCoreVersion)
+      .excludeAll(ExclusionRule(organization = "org.scala-lang"))
     val jacksonParameterNames = "com.fasterxml.jackson.module" % 
"jackson-module-parameter-names" % jacksonCoreVersion
     val jacksonCbor = "com.fasterxml.jackson.dataformat" % 
"jackson-dataformat-cbor" % jacksonCoreVersion
     val lz4Java = "org.lz4" % "lz4-java" % "1.8.0"
diff --git a/serialization-jackson/src/main/resources/reference.conf 
b/serialization-jackson/src/main/resources/reference.conf
index 1570411e47..9546bad105 100644
--- a/serialization-jackson/src/main/resources/reference.conf
+++ b/serialization-jackson/src/main/resources/reference.conf
@@ -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 {
diff --git 
a/serialization-jackson/src/main/scala/org/apache/pekko/serialization/jackson/JacksonObjectMapperProvider.scala
 
b/serialization-jackson/src/main/scala/org/apache/pekko/serialization/jackson/JacksonObjectMapperProvider.scala
index deae791ae6..9d527bdd88 100644
--- 
a/serialization-jackson/src/main/scala/org/apache/pekko/serialization/jackson/JacksonObjectMapperProvider.scala
+++ 
b/serialization-jackson/src/main/scala/org/apache/pekko/serialization/jackson/JacksonObjectMapperProvider.scala
@@ -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")
     }
   }
diff --git 
a/serialization-jackson/src/test/scala/org/apache/pekko/serialization/jackson/JacksonFactorySpec.scala
 
b/serialization-jackson/src/test/scala/org/apache/pekko/serialization/jackson/JacksonFactorySpec.scala
index 090b408037..d1a853d24c 100644
--- 
a/serialization-jackson/src/test/scala/org/apache/pekko/serialization/jackson/JacksonFactorySpec.scala
+++ 
b/serialization-jackson/src/test/scala/org/apache/pekko/serialization/jackson/JacksonFactorySpec.scala
@@ -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 {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to