From de2bbb24fe7d54a41df7db762d9845f0edf32ca4 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Mon, 11 Jul 2022 15:15:34 +0200 Subject: [PATCH 1/2] Use @All to inject ObjectMapperCustomizers This way, we are sure they are sorted by @Priority. And they can still be sorted by #getPriority(), this hasn't changed. --- .../io/quarkus/jackson/runtime/ObjectMapperProducer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/jackson/runtime/src/main/java/io/quarkus/jackson/runtime/ObjectMapperProducer.java b/extensions/jackson/runtime/src/main/java/io/quarkus/jackson/runtime/ObjectMapperProducer.java index 1c09d63e8b9ca..f71c3b89fa8f5 100644 --- a/extensions/jackson/runtime/src/main/java/io/quarkus/jackson/runtime/ObjectMapperProducer.java +++ b/extensions/jackson/runtime/src/main/java/io/quarkus/jackson/runtime/ObjectMapperProducer.java @@ -7,7 +7,6 @@ import java.util.TimeZone; import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Instance; import javax.enterprise.inject.Produces; import javax.inject.Singleton; @@ -17,6 +16,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import io.quarkus.arc.All; import io.quarkus.arc.DefaultBean; import io.quarkus.jackson.ObjectMapperCustomizer; @@ -26,7 +26,7 @@ public class ObjectMapperProducer { @DefaultBean @Singleton @Produces - public ObjectMapper objectMapper(Instance customizers, + public ObjectMapper objectMapper(@All List customizers, JacksonBuildTimeConfig jacksonBuildTimeConfig) { ObjectMapper objectMapper = new ObjectMapper(); if (!jacksonBuildTimeConfig.failOnUnknownProperties) { @@ -60,7 +60,7 @@ public ObjectMapper objectMapper(Instance customizers, } private List sortCustomizersInDescendingPriorityOrder( - Instance customizers) { + Iterable customizers) { List sortedCustomizers = new ArrayList<>(); for (ObjectMapperCustomizer customizer : customizers) { sortedCustomizers.add(customizer); From 17c0497e1669300d780093c90871c9c9a38ce5d8 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Mon, 11 Jul 2022 15:21:26 +0200 Subject: [PATCH 2/2] Make sure JsonbConfigCustomizers are sorted by @Priority --- .../src/main/java/io/quarkus/jsonb/JsonbProducer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/jsonb/runtime/src/main/java/io/quarkus/jsonb/JsonbProducer.java b/extensions/jsonb/runtime/src/main/java/io/quarkus/jsonb/JsonbProducer.java index faaf4bcddb5f0..ff39b5f1a8e77 100644 --- a/extensions/jsonb/runtime/src/main/java/io/quarkus/jsonb/JsonbProducer.java +++ b/extensions/jsonb/runtime/src/main/java/io/quarkus/jsonb/JsonbProducer.java @@ -1,13 +1,15 @@ package io.quarkus.jsonb; +import java.util.List; + import javax.enterprise.context.Dependent; -import javax.enterprise.inject.Instance; import javax.enterprise.inject.Produces; import javax.inject.Singleton; import javax.json.bind.Jsonb; import javax.json.bind.JsonbBuilder; import javax.json.bind.JsonbConfig; +import io.quarkus.arc.All; import io.quarkus.arc.DefaultBean; @Singleton @@ -16,7 +18,7 @@ public class JsonbProducer { @Produces @Dependent //JsonbConfig is not thread safe so it must not be made singleton. @DefaultBean - public JsonbConfig jsonbConfig(Instance customizers) { + public JsonbConfig jsonbConfig(@All List customizers) { JsonbConfig jsonbConfig = new JsonbConfig(); for (JsonbConfigCustomizer customizer : customizers) { customizer.customize(jsonbConfig);