From 6340ebbf700e034168a1a868f645e603dd53d3a9 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 9 Nov 2024 18:47:15 +0100 Subject: [PATCH 1/5] jackson 2.18.1 with max-token-count support --- .scala-steward.conf | 3 ++- project/Dependencies.scala | 2 +- serialization-jackson/src/main/resources/reference.conf | 2 ++ .../serialization/jackson/JacksonObjectMapperProvider.scala | 1 + .../pekko/serialization/jackson/JacksonFactorySpec.scala | 3 +++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.scala-steward.conf b/.scala-steward.conf index a11ccd80c2a..a0b314f601a 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 ef8690460a4..769e1e0482b 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -38,7 +38,7 @@ object Dependencies { val nettyVersion = "4.1.114.Final" val logbackVersion = "1.3.14" - val jacksonCoreVersion = "2.17.3" + val jacksonCoreVersion = "2.18.1" val jacksonDatabindVersion = jacksonCoreVersion val scala212Version = "2.12.20" diff --git a/serialization-jackson/src/main/resources/reference.conf b/serialization-jackson/src/main/resources/reference.conf index 1570411e479..cd4cc688385 100644 --- a/serialization-jackson/src/main/resources/reference.conf +++ b/serialization-jackson/src/main/resources/reference.conf @@ -59,6 +59,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 deae791ae66..de25eeefda8 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() 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 090b4080379..d1a853d24c3 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 { From 553ef11c8ee64b50ea18cce3b3d4a4d208e1f127 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 9 Nov 2024 19:54:25 +0100 Subject: [PATCH 2/5] Update Dependencies.scala --- project/Dependencies.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 769e1e0482b..30ccd57ccf7 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -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" From 1610fad6211648dc81f4cee476636657b269bf44 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 9 Nov 2024 20:02:53 +0100 Subject: [PATCH 3/5] remove lock-free buffer-recycler --- serialization-jackson/src/main/resources/reference.conf | 7 +++---- .../jackson/JacksonObjectMapperProvider.scala | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/serialization-jackson/src/main/resources/reference.conf b/serialization-jackson/src/main/resources/reference.conf index cd4cc688385..d708386eafd 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" 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" 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 de25eeefda8..42ae2c01153 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 @@ -160,8 +160,6 @@ 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")) From 466d3121b5669911923d2895529184b324b909d4 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 9 Nov 2024 20:50:32 +0100 Subject: [PATCH 4/5] add non-recycling pool --- serialization-jackson/src/main/resources/reference.conf | 2 +- .../serialization/jackson/JacksonObjectMapperProvider.scala | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/serialization-jackson/src/main/resources/reference.conf b/serialization-jackson/src/main/resources/reference.conf index d708386eafd..9546bad1052 100644 --- a/serialization-jackson/src/main/resources/reference.conf +++ b/serialization-jackson/src/main/resources/reference.conf @@ -39,7 +39,7 @@ pekko.serialization.jackson { # 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", "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" 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 42ae2c01153..9d527bdd88a 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 @@ -163,6 +163,7 @@ object JacksonObjectMapperProvider extends ExtensionId[JacksonObjectMapperProvid 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") } } From a58ffaf5c32bb973f7465823ce660a7310f93a33 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Thu, 28 Nov 2024 11:23:23 +0100 Subject: [PATCH 5/5] Update Dependencies.scala --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 30ccd57ccf7..cb854d85e1c 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -38,7 +38,7 @@ object Dependencies { val nettyVersion = "4.1.114.Final" val logbackVersion = "1.3.14" - val jacksonCoreVersion = "2.18.1" + val jacksonCoreVersion = "2.18.2" val jacksonDatabindVersion = jacksonCoreVersion val scala212Version = "2.12.20"