From 28b524b6fec04e8cbd4fc58bac2831c049add883 Mon Sep 17 00:00:00 2001 From: Maple Buice Date: Mon, 11 Dec 2023 12:56:14 -0500 Subject: [PATCH] Refine scope of Jackson module registration --- src/main/java/com/hubspot/jinjava/JinjavaConfig.java | 4 +--- .../com/hubspot/jinjava/lib/filter/PrettyPrintFilter.java | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/hubspot/jinjava/JinjavaConfig.java b/src/main/java/com/hubspot/jinjava/JinjavaConfig.java index 33e468734..99a54a784 100644 --- a/src/main/java/com/hubspot/jinjava/JinjavaConfig.java +++ b/src/main/java/com/hubspot/jinjava/JinjavaConfig.java @@ -19,7 +19,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.google.common.collect.ImmutableSet; import com.hubspot.jinjava.el.JinjavaInterpreterResolver; import com.hubspot.jinjava.el.JinjavaObjectUnwrapper; @@ -158,8 +157,7 @@ private JinjavaConfig(Builder builder) { private ObjectMapper setupObjectMapper(@Nullable ObjectMapper objectMapper) { if (objectMapper == null) { - objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); - + objectMapper = new ObjectMapper(); if (legacyOverrides.isUseSnakeCasePropertyNaming()) { objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); } diff --git a/src/main/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilter.java b/src/main/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilter.java index 41440d367..2c59e15c0 100644 --- a/src/main/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilter.java +++ b/src/main/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilter.java @@ -1,6 +1,7 @@ package com.hubspot.jinjava.lib.filter; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.hubspot.jinjava.doc.annotations.JinjavaDoc; import com.hubspot.jinjava.doc.annotations.JinjavaParam; import com.hubspot.jinjava.doc.annotations.JinjavaSnippet; @@ -55,6 +56,7 @@ public Object filter(Object var, JinjavaInterpreter interpreter, String... args) interpreter .getConfig() .getObjectMapper() + .registerModule(new JavaTimeModule()) .writerWithDefaultPrettyPrinter() .writeValueAsString(var); } catch (JsonProcessingException e) {