diff --git a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/util/JsonUtils.java b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/util/JsonUtils.java index e5e2fb40a36d..8e0fbf8ca2fb 100644 --- a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/util/JsonUtils.java +++ b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/util/JsonUtils.java @@ -18,6 +18,7 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.StreamReadConstraints; +import com.fasterxml.jackson.core.util.JsonRecyclerPools; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.MapperFeature; @@ -158,12 +159,14 @@ public static JsonFactory jsonFactory() // due to the limits introduced by Jackson 2.15 public static JsonFactoryBuilder jsonFactoryBuilder() { + // https://github.com/FasterXML/jackson-core/issues/1256 return new JsonFactoryBuilder() .streamReadConstraints(StreamReadConstraints.builder() .maxStringLength(Integer.MAX_VALUE) .maxNestingDepth(Integer.MAX_VALUE) .maxNumberLength(Integer.MAX_VALUE) - .build()); + .build()) + .recyclerPool(JsonRecyclerPools.threadLocalPool()); } private interface ParserConstructor diff --git a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/util/TestJsonUtils.java b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/util/TestJsonUtils.java index 7b2265b27227..2990dd843a83 100644 --- a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/util/TestJsonUtils.java +++ b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/util/TestJsonUtils.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.StreamReadConstraints; +import com.fasterxml.jackson.core.util.JsonRecyclerPools; import com.fasterxml.jackson.databind.JsonNode; import org.junit.jupiter.api.Test; @@ -81,6 +82,13 @@ public void testFactoryHasNoReadConstraints() assertReadConstraints(jsonFactoryBuilder().build().streamReadConstraints()); } + @Test + public void testFactoryHasThreadLocalRecycler() + { + assertThat(jsonFactory()._getRecyclerPool()).isEqualTo(JsonRecyclerPools.threadLocalPool()); + assertThat(jsonFactoryBuilder().build()._getRecyclerPool()).isEqualTo(JsonRecyclerPools.threadLocalPool()); + } + @Test public void testBuilderHasNoReadConstraints() {