From 6340ebbf700e034168a1a868f645e603dd53d3a9 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 9 Nov 2024 18:47:15 +0100 Subject: [PATCH] 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 {