From f3611700d5b76233cc22cc29e10201e1a10b8aee Mon Sep 17 00:00:00 2001 From: Francesco Nigro Date: Wed, 27 Mar 2024 12:30:24 +0100 Subject: [PATCH] Jackson should use HybridJacksonPool --- .../jackson/deployment/JacksonDefaultPoolTest.java | 14 ++++++++++++++ .../VertxHybridPoolObjectMapperCustomizer.java | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 extensions/jackson/deployment/src/test/java/io/quarkus/jackson/deployment/JacksonDefaultPoolTest.java diff --git a/extensions/jackson/deployment/src/test/java/io/quarkus/jackson/deployment/JacksonDefaultPoolTest.java b/extensions/jackson/deployment/src/test/java/io/quarkus/jackson/deployment/JacksonDefaultPoolTest.java new file mode 100644 index 00000000000000..715f9d62ff3ba2 --- /dev/null +++ b/extensions/jackson/deployment/src/test/java/io/quarkus/jackson/deployment/JacksonDefaultPoolTest.java @@ -0,0 +1,14 @@ +package io.quarkus.jackson.deployment; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.core.util.JsonRecyclerPools; + +public class JacksonDefaultPoolTest { + + @Test + public void validateDefaultJacksonPool() { + Assertions.assertThat(JsonRecyclerPools.defaultPool()).isInstanceOf(JsonRecyclerPools.LockFreePool.class); + } +} diff --git a/extensions/jackson/runtime/src/main/java/io/quarkus/jackson/runtime/VertxHybridPoolObjectMapperCustomizer.java b/extensions/jackson/runtime/src/main/java/io/quarkus/jackson/runtime/VertxHybridPoolObjectMapperCustomizer.java index 6f7bbe0cd3851e..139c8584ca0aae 100644 --- a/extensions/jackson/runtime/src/main/java/io/quarkus/jackson/runtime/VertxHybridPoolObjectMapperCustomizer.java +++ b/extensions/jackson/runtime/src/main/java/io/quarkus/jackson/runtime/VertxHybridPoolObjectMapperCustomizer.java @@ -10,7 +10,9 @@ public class VertxHybridPoolObjectMapperCustomizer implements ObjectMapperCustom @Override public void customize(ObjectMapper objectMapper) { - if (objectMapper.getFactory()._getRecyclerPool() == JsonRecyclerPools.defaultPool()) { + var existingMapperPool = objectMapper.getFactory()._getRecyclerPool(); + // JsonRecyclerPools.defaultPool() by default should create a LockFreePool + if (!(existingMapperPool instanceof JsonRecyclerPools.LockFreePool)) { objectMapper.getFactory().setRecyclerPool(HybridJacksonPool.getInstance()); } }