You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by nd...@apache.org on 2025/12/26 16:34:45 UTC

(tika) 01/01: TIKA-4589: Update ObjectMapper to use Jackson MapperBuilder pattern

This is an automated email from the ASF dual-hosted git repository.

ndipiazza pushed a commit to branch TIKA-4589
in repository https://gitbox.apache.org/repos/asf/tika.git

commit b2ed1a3ec9b98005d7c59b865cb74495ac82d21b
Author: Nicholas DiPiazza <nd...@apache.org>
AuthorDate: Fri Dec 26 10:34:31 2025 -0600

    TIKA-4589: Update ObjectMapper to use Jackson MapperBuilder pattern
    
    - Replace deprecated setDefaultPropertyInclusion() with builder pattern
    - Use JsonMapper.builder().defaultPropertyInclusion()
    - Compatible with Jackson 2.x and forward-compatible with 3.0
    - Removes deprecation warning and TODO comment
---
 .../main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java b/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java
index 29632929f..c7c3dd9bf 100644
--- a/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java
+++ b/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java
@@ -26,6 +26,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.json.JsonMapper;
 import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
 import com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator;
 import com.google.rpc.Status;
@@ -68,11 +69,9 @@ import org.apache.tika.plugins.TikaPluginManager;
 
 class TikaGrpcServerImpl extends TikaGrpc.TikaImplBase {
     private static final Logger LOG = LoggerFactory.getLogger(TikaGrpcServerImpl.class);
-    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-    static {
-        //TODO with Jackson 3.0 we'll have to use MapperBuilder
-        OBJECT_MAPPER.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
-    }
+    private static final ObjectMapper OBJECT_MAPPER = JsonMapper.builder()
+            .defaultPropertyInclusion(JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL))
+            .build();
     public static final JsonSchemaGenerator JSON_SCHEMA_GENERATOR = new JsonSchemaGenerator(OBJECT_MAPPER);
 
     PipesConfig pipesConfig;