diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java index f5665da9d16f5..e08c17a8661a9 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java @@ -291,7 +291,8 @@ public void setupEndpoints(Capabilities capabilities, BeanArchiveIndexBuildItem config.inputBufferSize.asLongValue(), config.singleDefaultProduces, config.defaultProduces)) .setAdditionalReaders(additionalReaders) .setHttpAnnotationToMethod(result.getHttpAnnotationToMethod()) - .setInjectableBeans(injectableBeans).setAdditionalWriters(additionalWriters) + .setInjectableBeans(injectableBeans) + .setAdditionalWriters(additionalWriters) .setDefaultBlocking(appResult.isBlocking()) .setHasRuntimeConverters(!paramConverterProviders.getParamConverterProviders().isEmpty()) .setClassLevelExceptionMappers( diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/ApplicationWithBlockingTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/ApplicationWithBlockingTest.java new file mode 100644 index 0000000000000..4abbe528c48a2 --- /dev/null +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/ApplicationWithBlockingTest.java @@ -0,0 +1,63 @@ +package io.quarkus.resteasy.reactive.server.test.simple; + +import java.util.function.Supplier; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Application; + +import org.hamcrest.Matchers; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.restassured.RestAssured; +import io.smallrye.common.annotation.Blocking; +import io.smallrye.common.annotation.NonBlocking; + +public class ApplicationWithBlockingTest { + + @RegisterExtension + static QuarkusUnitTest test = new QuarkusUnitTest() + .setArchiveProducer(new Supplier() { + @Override + public JavaArchive get() { + return ShrinkWrap.create(JavaArchive.class) + .addClasses(BlockingApplication.class, ThreadNameResource.class); + } + }); + + @Test + public void test() { + RestAssured.get("/tname/blocking") + .then().body(Matchers.containsString("executor"), Matchers.not(Matchers.containsString("loop"))); + + RestAssured.get("/tname/nonblocking") + .then().body(Matchers.containsString("loop"), Matchers.not(Matchers.containsString("executor"))); + } + + @Blocking + public static class BlockingApplication extends Application { + + } + + @Path("tname") + public static class ThreadNameResource { + + @Path("blocking") + @GET + public String threadName() { + return Thread.currentThread().getName(); + } + + @NonBlocking + @Path("nonblocking") + @GET + public String nonBlocking() { + return Thread.currentThread().getName(); + } + } + +} 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 cdce7ab7e3e5a..7a299d0d9aa83 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 @@ -20,6 +20,7 @@ import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.LONG; import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.MATRIX_PARAM; import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.MULTI; +import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.NON_BLOCKING; import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.PATH; import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.PATH_PARAM; import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.PATH_SEGMENT; @@ -438,11 +439,11 @@ private ResourceMethod createResourceMethod(ClassInfo currentClassInfo, ClassInf boolean blocking = defaultBlocking; AnnotationInstance blockingAnnotation = getInheritableAnnotation(info, BLOCKING); if (blockingAnnotation != null) { - AnnotationValue value = blockingAnnotation.value(); - if (value != null) { - blocking = value.asBoolean(); - } else { - blocking = true; + blocking = true; + } else { + AnnotationInstance nonBlockingAnnotation = getInheritableAnnotation(info, NON_BLOCKING); + if (nonBlockingAnnotation != null) { + blocking = false; } } diff --git a/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java b/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java index 621a249ee05cb..c37f18504f718 100644 --- a/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java +++ b/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java @@ -84,10 +84,10 @@ public static ApplicationScanningResult scanForApplicationClass(IndexView index) | InvocationTargetException e) { throw new RuntimeException("Unable to handle class: " + applicationClass, e); } - if (applicationClassInfo.classAnnotation(ResteasyReactiveDotNames.NON_BLOCKING) != null) { - blocking = false; - } else if (applicationClassInfo.classAnnotation(ResteasyReactiveDotNames.NON_BLOCKING) != null) { + if (applicationClassInfo.classAnnotation(ResteasyReactiveDotNames.BLOCKING) != null) { blocking = true; + } else if (applicationClassInfo.classAnnotation(ResteasyReactiveDotNames.NON_BLOCKING) != null) { + blocking = false; } } if (selectedAppClass != null) {