summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@yahooinc.com>2023-05-09 15:46:32 +0200
committerBjørn Christian Seime <bjorncs@yahooinc.com>2023-05-09 15:59:59 +0200
commitad7aed9bb7b529cc98acf46763cd869523296fbc (patch)
tree1025fa907e90eefd7587b81f90ad6fbb575dc8c6 /container-core
parent9904aaf25710c6affca4140c22fa99501eb325fd (diff)
Disable string length restriction introduced in Jackson 2.15
Disable restriction only for parsers/generators which is likely to handle literals exceeding 5M
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/restapi/JacksonJsonMapper.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/container-core/src/main/java/com/yahoo/restapi/JacksonJsonMapper.java b/container-core/src/main/java/com/yahoo/restapi/JacksonJsonMapper.java
index 6ed9bead0ba..e23401aa882 100644
--- a/container-core/src/main/java/com/yahoo/restapi/JacksonJsonMapper.java
+++ b/container-core/src/main/java/com/yahoo/restapi/JacksonJsonMapper.java
@@ -1,6 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.restapi;
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonFactoryBuilder;
+import com.fasterxml.jackson.core.StreamReadConstraints;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
@@ -13,10 +16,17 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
*/
class JacksonJsonMapper {
- static final ObjectMapper instance = new ObjectMapper()
+ static final ObjectMapper instance = new ObjectMapper(createFactory())
.registerModule(new JavaTimeModule())
.registerModule(new Jdk8Module())
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
private JacksonJsonMapper() {}
+
+ private static JsonFactory createFactory() {
+ return new JsonFactoryBuilder()
+ .streamReadConstraints(StreamReadConstraints.builder().maxStringLength(Integer.MAX_VALUE).build())
+ .build();
+
+ }
}