Skip to content

Commit

Permalink
Merge pull request #38196 from mariofusco/jackson_vertx_pool
Browse files Browse the repository at this point in the history
Use Vert.x pool with Jackson
  • Loading branch information
geoand authored Feb 2, 2024
2 parents 35c60b8 + 672acbf commit 70f2e68
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import io.quarkus.jackson.runtime.JacksonSupportRecorder;
import io.quarkus.jackson.runtime.MixinsRecorder;
import io.quarkus.jackson.runtime.ObjectMapperProducer;
import io.quarkus.jackson.runtime.VertxHybridPoolObjectMapperCustomizer;
import io.quarkus.jackson.spi.ClassPathJacksonModuleBuildItem;
import io.quarkus.jackson.spi.JacksonModuleBuildItem;

Expand Down Expand Up @@ -108,9 +109,11 @@ public class JacksonProcessor {
List<IgnoreJsonDeserializeClassBuildItem> ignoreJsonDeserializeClassBuildItems;

@BuildStep
void unremovable(Capabilities capabilities, BuildProducer<UnremovableBeanBuildItem> producer) {
void unremovable(Capabilities capabilities, BuildProducer<UnremovableBeanBuildItem> producer,
BuildProducer<AdditionalBeanBuildItem> additionalProducer) {
if (capabilities.isPresent(Capability.VERTX_CORE)) {
producer.produce(UnremovableBeanBuildItem.beanTypes(ObjectMapper.class));
additionalProducer.produce(AdditionalBeanBuildItem.unremovableOf(VertxHybridPoolObjectMapperCustomizer.class));
}
}

Expand Down
5 changes: 5 additions & 0 deletions extensions/jackson/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.quarkus.jackson.runtime;

import com.fasterxml.jackson.core.util.JsonRecyclerPools;
import com.fasterxml.jackson.databind.ObjectMapper;

import io.quarkus.jackson.ObjectMapperCustomizer;
import io.vertx.core.json.jackson.HybridJacksonPool;

public class VertxHybridPoolObjectMapperCustomizer implements ObjectMapperCustomizer {

@Override
public void customize(ObjectMapper objectMapper) {
if (objectMapper.getFactory()._getRecyclerPool() == JsonRecyclerPools.defaultPool()) {
objectMapper.getFactory().setRecyclerPool(HybridJacksonPool.getInstance());
}
}
}

0 comments on commit 70f2e68

Please sign in to comment.