From a311198f5b3fe9acfbd69f42c36693b65e26e200 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 27 Sep 2024 23:13:20 +0100 Subject: [PATCH] support jackson max token count --- .../src/main/resources/reference.conf | 14 ++++++++------ .../pekkohttpjackson/JacksonSupport.scala | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pekko-http-jackson/src/main/resources/reference.conf b/pekko-http-jackson/src/main/resources/reference.conf index b01a1bd..7d9f34b 100644 --- a/pekko-http-jackson/src/main/resources/reference.conf +++ b/pekko-http-jackson/src/main/resources/reference.conf @@ -2,30 +2,32 @@ pekko-http-json { jackson { jackson-modules += "com.fasterxml.jackson.module.scala.DefaultScalaModule" read { - # see https://www.javadoc.io/static/com.fasterxml.jackson.core/jackson-core/2.16.0/com/fasterxml/jackson/core/StreamReadConstraints.html + # see https://www.javadoc.io/static/com.fasterxml.jackson.core/jackson-core/2.18.0/com/fasterxml/jackson/core/StreamReadConstraints.html # these defaults are the same as the defaults in `StreamReadConstraints` max-nesting-depth = 1000 max-number-length = 1000 max-string-length = 20000000 - # following were added in jackson 2.16.0 + # added in jackson 2.16.0 max-name-length = 50000 - # max-document-length of -1 means unlimited + # max-document-length of -1 means unlimited (since jackson 2.16.0) max-document-length = -1 + # max-token-count of -1 means unlimited (since jackson 2.18.0) + max-token-count = -1 - # see https://www.javadoc.io/static/com.fasterxml.jackson.core/jackson-core/2.16.0/com/fasterxml/jackson/core/StreamReadFeature.html + # see https://www.javadoc.io/static/com.fasterxml.jackson.core/jackson-core/2.18.0/com/fasterxml/jackson/core/StreamReadFeature.html # these defaults are the same as the defaults in `StreamReadFeature` feature { include-source-in-location = false } } write { - # see https://www.javadoc.io/static/com.fasterxml.jackson.core/jackson-core/2.16.0/com/fasterxml/jackson/core/StreamWriteConstraints.html + # see https://www.javadoc.io/static/com.fasterxml.jackson.core/jackson-core/2.18.0/com/fasterxml/jackson/core/StreamWriteConstraints.html # these defaults are the same as the defaults in `StreamWriteConstraints` max-nesting-depth = 1000 } # Controls the Buffer Recycler Pool implementation used by Jackson. - # https://javadoc.io/static/com.fasterxml.jackson.core/jackson-core/2.16.2/com/fasterxml/jackson/core/util/JsonRecyclerPools.html + # https://javadoc.io/static/com.fasterxml.jackson.core/jackson-core/2.18.0/com/fasterxml/jackson/core/util/JsonRecyclerPools.html # The default is "thread-local" which is the same as the default in Jackson 2.16. buffer-recycler { # the supported values are "thread-local", "lock-free", "shared-lock-free", "concurrent-deque", diff --git a/pekko-http-jackson/src/main/scala/com/github/pjfanning/pekkohttpjackson/JacksonSupport.scala b/pekko-http-jackson/src/main/scala/com/github/pjfanning/pekkohttpjackson/JacksonSupport.scala index fea481f..6dd6827 100644 --- a/pekko-http-jackson/src/main/scala/com/github/pjfanning/pekkohttpjackson/JacksonSupport.scala +++ b/pekko-http-jackson/src/main/scala/com/github/pjfanning/pekkohttpjackson/JacksonSupport.scala @@ -72,6 +72,7 @@ object JacksonSupport extends JacksonSupport { .maxStringLength(config.getInt("read.max-string-length")) .maxNameLength(config.getInt("read.max-name-length")) .maxDocumentLength(config.getInt("read.max-document-length")) + .maxTokenCount(config.getInt("read.max-token-count")) .build() val streamWriteConstraints = StreamWriteConstraints .builder()