Skip to content

Commit 70f2e68

Browse files
authored
Merge pull request #38196 from mariofusco/jackson_vertx_pool
Use Vert.x pool with Jackson
2 parents 35c60b8 + 672acbf commit 70f2e68

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

extensions/jackson/deployment/src/main/java/io/quarkus/jackson/deployment/JacksonProcessor.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import io.quarkus.jackson.runtime.JacksonSupportRecorder;
6969
import io.quarkus.jackson.runtime.MixinsRecorder;
7070
import io.quarkus.jackson.runtime.ObjectMapperProducer;
71+
import io.quarkus.jackson.runtime.VertxHybridPoolObjectMapperCustomizer;
7172
import io.quarkus.jackson.spi.ClassPathJacksonModuleBuildItem;
7273
import io.quarkus.jackson.spi.JacksonModuleBuildItem;
7374

@@ -108,9 +109,11 @@ public class JacksonProcessor {
108109
List<IgnoreJsonDeserializeClassBuildItem> ignoreJsonDeserializeClassBuildItems;
109110

110111
@BuildStep
111-
void unremovable(Capabilities capabilities, BuildProducer<UnremovableBeanBuildItem> producer) {
112+
void unremovable(Capabilities capabilities, BuildProducer<UnremovableBeanBuildItem> producer,
113+
BuildProducer<AdditionalBeanBuildItem> additionalProducer) {
112114
if (capabilities.isPresent(Capability.VERTX_CORE)) {
113115
producer.produce(UnremovableBeanBuildItem.beanTypes(ObjectMapper.class));
116+
additionalProducer.produce(AdditionalBeanBuildItem.unremovableOf(VertxHybridPoolObjectMapperCustomizer.class));
114117
}
115118
}
116119

extensions/jackson/runtime/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
<groupId>io.quarkus</groupId>
3434
<artifactId>quarkus-arc</artifactId>
3535
</dependency>
36+
<dependency>
37+
<groupId>io.vertx</groupId>
38+
<artifactId>vertx-core</artifactId>
39+
<optional>true</optional>
40+
</dependency>
3641
</dependencies>
3742

3843
<build>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.quarkus.jackson.runtime;
2+
3+
import com.fasterxml.jackson.core.util.JsonRecyclerPools;
4+
import com.fasterxml.jackson.databind.ObjectMapper;
5+
6+
import io.quarkus.jackson.ObjectMapperCustomizer;
7+
import io.vertx.core.json.jackson.HybridJacksonPool;
8+
9+
public class VertxHybridPoolObjectMapperCustomizer implements ObjectMapperCustomizer {
10+
11+
@Override
12+
public void customize(ObjectMapper objectMapper) {
13+
if (objectMapper.getFactory()._getRecyclerPool() == JsonRecyclerPools.defaultPool()) {
14+
objectMapper.getFactory().setRecyclerPool(HybridJacksonPool.getInstance());
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)