OAK-9311 oak-search-elastic: disable String.intern when deserializing

git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1885391 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticResponseHandler.java b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticResponseHandler.java
index 7eff471..1513922 100644
--- a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticResponseHandler.java
+++ b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticResponseHandler.java
@@ -18,6 +18,8 @@
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonFactoryBuilder;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.jackrabbit.oak.plugins.index.search.FieldNames;
@@ -42,7 +44,12 @@
 
     private static final ObjectMapper JSON_MAPPER;
     static {
-        JSON_MAPPER = new ObjectMapper();
+        // disable String.intern
+        // https://github.com/elastic/elasticsearch/issues/39890
+        // https://github.com/FasterXML/jackson-core/issues/332
+        JsonFactoryBuilder factoryBuilder = new JsonFactoryBuilder();
+        factoryBuilder.disable(JsonFactory.Feature.INTERN_FIELD_NAMES);
+        JSON_MAPPER = new ObjectMapper(factoryBuilder.build());
         JSON_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
     }