From ef535f6c51393d945d9fe07de38de224d5ae443f Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 23 Nov 2023 16:07:43 +0100 Subject: jackson 2.16 changes some of its default settings so we consolidate our use of the ObjectMapper. Unless special options are used, use a common instance, or create via factory metod. --- .../vespa/filedistribution/status/FileDistributionStatusClient.java | 5 ++--- .../src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'vespaclient-java/src') diff --git a/vespaclient-java/src/main/java/com/yahoo/vespa/filedistribution/status/FileDistributionStatusClient.java b/vespaclient-java/src/main/java/com/yahoo/vespa/filedistribution/status/FileDistributionStatusClient.java index 8bb3bda1cb4..6e688c7737e 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespa/filedistribution/status/FileDistributionStatusClient.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespa/filedistribution/status/FileDistributionStatusClient.java @@ -1,9 +1,9 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.filedistribution.status; +import ai.vespa.json.Jackson; import ai.vespa.util.http.hc5.VespaHttpClientBuilder; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import io.airlift.airline.Command; import io.airlift.airline.HelpOption; import io.airlift.airline.Option; @@ -102,10 +102,9 @@ public class FileDistributionStatusClient { } String parseAndGenerateOutput(String json) { - ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode; try { - jsonNode = objectMapper.readTree(json); + jsonNode = Jackson.mapper().readTree(json); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java index 2ea38a75ea0..223d62ea323 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java @@ -1,7 +1,7 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespaget; -import com.fasterxml.jackson.databind.ObjectMapper; +import ai.vespa.json.Jackson; import com.yahoo.document.DataType; import com.yahoo.document.Document; import com.yahoo.document.DocumentId; @@ -182,9 +182,8 @@ public class DocumentRetrieverTest { documentRetriever.retrieveDocuments(); verify(mockedSession, times(3)).syncSend(any()); - ObjectMapper m = new ObjectMapper(); @SuppressWarnings("unchecked") - List> feed = m.readValue(outContent.toByteArray(), List.class); + List> feed = Jackson.mapper().readValue(outContent.toByteArray(), List.class); assertEquals(DOC_ID_1, feed.get(0).get("id")); assertEquals(DOC_ID_2, feed.get(1).get("id")); assertEquals(DOC_ID_3, feed.get(2).get("id")); -- cgit v1.2.3