diff --git a/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java b/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java index 5765512492d59..693fa764d6eba 100644 --- a/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java +++ b/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java @@ -135,6 +135,13 @@ void disableDefaultExceptionMapper(BuildProducer system systemProperties.produce(new SystemPropertyBuildItem("dev.resteasy.exception.mapper", "false")); } + @BuildStep + void setupRestEasyManualProviders(BuildProducer providers) { + // this one is added manually in RESTEasy's ResteasyDeploymentImpl + // https://github.com/quarkusio/quarkus/issues/13667 + providers.produce(new ResteasyJaxrsProviderBuildItem(ServerFormUrlEncodedProvider.class.getName())); + } + @BuildStep void setupGzipProviders(BuildProducer providers) { // If GZIP support is enabled, enable it @@ -164,22 +171,8 @@ JaxrsProvidersToRegisterBuildItem setupProviders(BuildProducer contributedProviders = new HashSet<>(); - for (ResteasyJaxrsProviderBuildItem contributedProviderBuildItem : contributedProviderBuildItems) { - contributedProviders.add(contributedProviderBuildItem.getName()); - } - - Set annotatedProviders = new HashSet<>(); - for (AnnotationInstance i : indexBuildItem.getIndex().getAnnotations(ResteasyDotNames.PROVIDER)) { - if (i.target().kind() == AnnotationTarget.Kind.CLASS) { - annotatedProviders.add(i.target().asClass().name().toString()); - } - } - contributedProviders.addAll(annotatedProviders); Set availableProviders = new HashSet<>(ServiceUtil.classNamesNamedIn(getClass().getClassLoader(), "META-INF/services/" + Providers.class.getName())); - // this one is added manually in RESTEasy's ResteasyDeploymentImpl - availableProviders.add(ServerFormUrlEncodedProvider.class.getName()); MediaTypeMap categorizedReaders = new MediaTypeMap<>(); MediaTypeMap categorizedWriters = new MediaTypeMap<>(); @@ -189,9 +182,6 @@ JaxrsProvidersToRegisterBuildItem setupProviders(BuildProducer providersToRegister = new HashSet<>(otherProviders); - if (!capabilities.isPresent(Capability.VERTX) && !capabilities.isCapabilityWithPrefixPresent(Capability.RESTEASY_JSON)) { @@ -219,6 +209,8 @@ JaxrsProvidersToRegisterBuildItem setupProviders(BuildProducer providersToRegister = new HashSet<>(otherProviders); // we add a couple of default providers providersToRegister.add(StringTextStar.class.getName()); providersToRegister.addAll(categorizedWriters.getPossible(MediaType.APPLICATION_JSON_TYPE)); @@ -231,11 +223,32 @@ JaxrsProvidersToRegisterBuildItem setupProviders(BuildProducer contributedProviders = new HashSet<>(); + for (ResteasyJaxrsProviderBuildItem contributedProviderBuildItem : contributedProviderBuildItems) { + // If we use built-in providers, we can ignore duplicate entries + if (!useBuiltinProviders || !availableProviders.contains(contributedProviderBuildItem.getName())) { + contributedProviders.add(contributedProviderBuildItem.getName()); + } + } + + Set annotatedProviders = new HashSet<>(); + for (AnnotationInstance i : indexBuildItem.getIndex().getAnnotations(ResteasyDotNames.PROVIDER)) { + if (i.target().kind() == AnnotationTarget.Kind.CLASS) { + String annotatedProvider = i.target().asClass().name().toString(); + // If we use build-in providers, we can ignore duplicate entries + if (!useBuiltinProviders || !availableProviders.contains(annotatedProvider)) { + annotatedProviders.add(annotatedProvider); + } + } + } + contributedProviders.addAll(annotatedProviders); + + providersToRegister.addAll(contributedProviders); if (useBuiltinProviders) { - providersToRegister = new HashSet<>(contributedProviders); - providersToRegister.addAll(availableProviders); - } else { - providersToRegister.addAll(contributedProviders); + // If we use built-in providers, we need to register all available providers + for (String availableProvider : availableProviders) { + reflectiveClass.produce(ReflectiveClassBuildItem.builder(availableProvider).fields().build()); + } } if (providersToRegister.contains("org.jboss.resteasy.plugins.providers.jsonb.JsonBindingProvider")) {