diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/QuarkusServerEndpointIndexer.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/QuarkusServerEndpointIndexer.java index 16b6355c47190..76fdcbbb826d4 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/QuarkusServerEndpointIndexer.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/QuarkusServerEndpointIndexer.java @@ -15,6 +15,9 @@ import org.jboss.logging.Logger; import org.jboss.resteasy.reactive.common.ResteasyReactiveConfig; import org.jboss.resteasy.reactive.common.processor.DefaultProducesHandler; +import org.jboss.resteasy.reactive.common.processor.scanning.ResteasyReactiveScanner; +import org.jboss.resteasy.reactive.common.processor.scanning.ScannedSerializer; +import org.jboss.resteasy.reactive.common.processor.scanning.SerializerScanningResult; import org.jboss.resteasy.reactive.common.processor.transformation.AnnotationStore; import org.jboss.resteasy.reactive.server.model.ServerResourceMethod; import org.jboss.resteasy.reactive.server.processor.ServerEndpointIndexer; @@ -43,6 +46,7 @@ public class QuarkusServerEndpointIndexer private final ResteasyReactiveRecorder resteasyReactiveRecorder; private final Predicate applicationClassPredicate; + private SerializerScanningResult serializerScanningResult; QuarkusServerEndpointIndexer(Builder builder) { super(builder); @@ -170,10 +174,33 @@ private void warnAboutMissingJsonProviderIfNeeded(ServerResourceMethod method, M return; } if (hasJson(method) || (hasNoTypesDefined(method) && isDefaultJson())) { - LOGGER.warnf("Quarkus detected the use of JSON in JAX-RS method '" + info.declaringClass().name() + "#" - + info.name() - + "' but no JSON extension has been added. Consider adding 'quarkus-resteasy-reactive-jackson' or 'quarkus-resteasy-reactive-jsonb'."); + if (serializerScanningResult == null) { + serializerScanningResult = ResteasyReactiveScanner.scanForSerializers(index, applicationScanningResult); + } + boolean appProvidedJsonReaderExists = appProvidedJsonProviderExists(serializerScanningResult.getReaders()); + boolean appProvidedJsonWriterExists = appProvidedJsonProviderExists(serializerScanningResult.getWriters()); + if (!appProvidedJsonReaderExists || !appProvidedJsonWriterExists) { + LOGGER.warnf("Quarkus detected the use of JSON in JAX-RS method '" + info.declaringClass().name() + "#" + + info.name() + + "' but no JSON extension has been added. Consider adding 'quarkus-resteasy-reactive-jackson' or 'quarkus-resteasy-reactive-jsonb'."); + } + } + } + + private boolean appProvidedJsonProviderExists(List providers) { + boolean appProvidedJsonReaderExists = false; + for (ScannedSerializer provider : providers) { + for (String mt : provider.getMediaTypeStrings()) { + if (isJson(mt)) { + appProvidedJsonReaderExists = true; + break; + } + } + if (appProvidedJsonReaderExists) { + break; + } } + return appProvidedJsonReaderExists; } private boolean isDefaultJson() { diff --git a/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java b/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java index 072551ecfebc7..4ee14ffe8f5b1 100644 --- a/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java +++ b/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java @@ -226,7 +226,7 @@ public abstract class EndpointIndexer> factoryCreator; private final Consumer resourceMethodCallback; private final AnnotationStore annotationStore; - private final ApplicationScanningResult applicationScanningResult; + protected final ApplicationScanningResult applicationScanningResult; private final Set contextTypes; private final MultipartReturnTypeIndexerExtension multipartReturnTypeIndexerExtension; private final MultipartParameterIndexerExtension multipartParameterIndexerExtension;