From 87aaa562066c1127c649a1b6ebf2b86007730f13 Mon Sep 17 00:00:00 2001 From: Thomas Segismont Date: Tue, 6 Feb 2024 09:17:36 +0100 Subject: [PATCH] Load pretty mapper eagerly Signed-off-by: Thomas Segismont --- .../io/vertx/core/json/jackson/DatabindCodec.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/vertx/core/json/jackson/DatabindCodec.java b/src/main/java/io/vertx/core/json/jackson/DatabindCodec.java index fd3ffc991b6..d1867fd09f8 100644 --- a/src/main/java/io/vertx/core/json/jackson/DatabindCodec.java +++ b/src/main/java/io/vertx/core/json/jackson/DatabindCodec.java @@ -27,7 +27,6 @@ import java.io.InputStream; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; /** * @author Julien Viet @@ -35,10 +34,11 @@ public class DatabindCodec extends JacksonCodec { private static final ObjectMapper mapper = new ObjectMapper(); - private static final AtomicReference prettyMapper = new AtomicReference<>(); + private static final ObjectMapper prettyMapper = new ObjectMapper(); static { initialize(mapper, false); + initialize(prettyMapper, true); } private static void initialize(ObjectMapper om, boolean prettyPrint) { @@ -64,13 +64,7 @@ public static ObjectMapper mapper() { */ @Deprecated public static ObjectMapper prettyMapper() { - ObjectMapper pm = prettyMapper.get(); - if (pm != null) { - return pm; - } - pm = new ObjectMapper(); - initialize(pm, true); - return prettyMapper.compareAndSet(null, pm) ? pm : prettyMapper.get(); + return prettyMapper; } @Override