From fa80c8dbfe68d0d2a8d7cb9592d5ccfc585fe7b7 Mon Sep 17 00:00:00 2001 From: david-leifker <114954101+david-leifker@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:47:28 -0500 Subject: [PATCH] refactor(): use static yaml mapper es search service (#13016) --- .../search/ElasticSearchServiceFactory.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/metadata-service/factories/src/main/java/com/linkedin/gms/factory/search/ElasticSearchServiceFactory.java b/metadata-service/factories/src/main/java/com/linkedin/gms/factory/search/ElasticSearchServiceFactory.java index d921e20f72..1b5f998bbb 100644 --- a/metadata-service/factories/src/main/java/com/linkedin/gms/factory/search/ElasticSearchServiceFactory.java +++ b/metadata-service/factories/src/main/java/com/linkedin/gms/factory/search/ElasticSearchServiceFactory.java @@ -2,9 +2,6 @@ package com.linkedin.gms.factory.search; import static com.linkedin.metadata.Constants.*; -import com.fasterxml.jackson.core.StreamReadConstraints; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; import com.linkedin.gms.factory.config.ConfigurationProvider; import com.linkedin.gms.factory.entityregistry.EntityRegistryFactory; import com.linkedin.metadata.config.search.ElasticSearchConfiguration; @@ -17,6 +14,7 @@ import com.linkedin.metadata.search.elasticsearch.query.ESBrowseDAO; import com.linkedin.metadata.search.elasticsearch.query.ESSearchDAO; import com.linkedin.metadata.search.elasticsearch.query.filter.QueryFilterRewriteChain; import com.linkedin.metadata.search.elasticsearch.update.ESWriteDAO; +import io.datahubproject.metadata.context.ObjectMapperContext; import java.io.IOException; import javax.annotation.Nonnull; import lombok.extern.slf4j.Slf4j; @@ -30,17 +28,6 @@ import org.springframework.context.annotation.Import; @Configuration @Import({EntityRegistryFactory.class, SettingsBuilderFactory.class}) public class ElasticSearchServiceFactory { - private static final ObjectMapper YAML_MAPPER = new YAMLMapper(); - - static { - int maxSize = - Integer.parseInt( - System.getenv() - .getOrDefault(INGESTION_MAX_SERIALIZED_STRING_LENGTH, MAX_JACKSON_STRING_SIZE)); - YAML_MAPPER - .getFactory() - .setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(maxSize).build()); - } @Autowired @Qualifier("baseElasticSearchComponents") @@ -68,7 +55,7 @@ public class ElasticSearchServiceFactory { CustomSearchConfiguration customSearchConfiguration = searchConfiguration.getCustom() == null ? null - : searchConfiguration.getCustom().resolve(YAML_MAPPER); + : searchConfiguration.getCustom().resolve(ObjectMapperContext.DEFAULT.getYamlMapper()); ESSearchDAO esSearchDAO = new ESSearchDAO(