diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/failures/FailingClientResource.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/failures/FailingClientResource.java new file mode 100644 index 0000000000..e56ce07ab5 --- /dev/null +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/failures/FailingClientResource.java @@ -0,0 +1,31 @@ +package io.quarkus.ts.http.restclient.reactive.failures; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +import org.eclipse.microprofile.rest.client.inject.RestClient; + +import io.smallrye.mutiny.Uni; + +@Path("/client/failing") +public class FailingClientResource { + @RestClient + FailureClient client; + + @GET + @Produces(MediaType.TEXT_PLAIN) + @Path("/straight") + public String getStraightResult() { + return client.getVisitor(); + } + + @GET + @Produces(MediaType.TEXT_PLAIN) + @Path("/reactive") + public Uni getReactiveResult() { + return client.getVisitorReactively() + .onFailure().retry().atMost(5); + } +} diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/failures/FailingResource.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/failures/FailingResource.java new file mode 100644 index 0000000000..27c9fbc032 --- /dev/null +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/failures/FailingResource.java @@ -0,0 +1,28 @@ +package io.quarkus.ts.http.restclient.reactive.failures; + +import java.util.concurrent.atomic.AtomicInteger; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path("/fail") +public class FailingResource { + private static final AtomicInteger counter = new AtomicInteger(0); + private static final boolean[] fail = { true, true, true, true, false }; + // in earlier versions, connection was closed after three errors. We need to ensure, that this is no a case. + + @GET + @Produces(MediaType.TEXT_PLAIN) + @Path("/cyclic") + public String fail() { + int visit = counter.getAndIncrement(); + int index = visit % fail.length; + if (fail[index]) { + throw new RuntimeException("Whoops, we encountered a problem!"); + } else { + return "You're the " + (visit + 1) + "th visitor of this page"; + } + } +} diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/failures/FailureClient.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/failures/FailureClient.java new file mode 100644 index 0000000000..994427edb3 --- /dev/null +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/failures/FailureClient.java @@ -0,0 +1,25 @@ +package io.quarkus.ts.http.restclient.reactive.failures; + +import java.time.temporal.ChronoUnit; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; + +import org.eclipse.microprofile.faulttolerance.Retry; +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +import io.smallrye.mutiny.Uni; + +@RegisterRestClient(baseUri = "http://localhost:8080/") +@Path("/fail") +public interface FailureClient { + + @GET + @Retry(delay = 1, delayUnit = ChronoUnit.SECONDS, maxRetries = 5) + @Path("/cyclic") + String getVisitor(); + + @GET + @Path("/cyclic") + Uni getVisitorReactively(); +} diff --git a/http/rest-client-reactive/src/main/resources/modern.properties b/http/rest-client-reactive/src/main/resources/modern.properties index f549a895c4..13e4f0ffbb 100644 --- a/http/rest-client-reactive/src/main/resources/modern.properties +++ b/http/rest-client-reactive/src/main/resources/modern.properties @@ -5,6 +5,7 @@ quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.BookClient".url=http quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.BookClient.AuthorClient".url=http://localhost:${quarkus.http.port} quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.ResourceAndSubResourcesClient".url=http://localhost:${quarkus.http.port} quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.MalformedClient".url=http://localhost:${quarkus.http.port} +quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.failures.FailureClient".url=http://localhost:${quarkus.http.port} quarkus.rest-client.logging.scope=request-response quarkus.log.category."org.jboss.resteasy.reactive.client.logging".level=DEBUG diff --git a/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/ReactiveRestClientIT.java b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/ReactiveRestClientIT.java index c580aba9b5..73b88cb4a4 100644 --- a/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/ReactiveRestClientIT.java +++ b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/ReactiveRestClientIT.java @@ -46,6 +46,7 @@ public class ReactiveRestClientIT { } static final String MALFORMED_URL = "quarkus.rest-client.\"io.quarkus.ts.http.restclient.reactive.MalformedClient\".url"; + @QuarkusApplication static RestService app = new RestService() .withProperties("modern.properties") @@ -275,6 +276,24 @@ public void clientHeaderInjectionTest() { .body(containsString("clientFilterInvoked")); } + @Test + @Tag("https://github.com/quarkusio/quarkus/issues/37323") + public void clientRetry() { + app.given().get("/client/failing/straight") + .then() + .statusCode(200) + .body(containsString("visitor of this page")); + } + + @Test + @Tag("https://github.com/quarkusio/quarkus/issues/37323") + public void clientReactiveRetry() { + app.given().get("/client/failing/reactive") + .then() + .statusCode(200) + .body(containsString("visitor of this page")); + } + @AfterAll static void afterAll() { mockServer.stop(); diff --git a/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateJvmApplicationIT.java b/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateJvmApplicationIT.java index 512d90c741..c7d59636d9 100644 --- a/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateJvmApplicationIT.java +++ b/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateJvmApplicationIT.java @@ -309,7 +309,6 @@ public void shouldCreateJacocoReportsFromApplicationOnJvm() { @Tag("QUARKUS-1296") @Test - @Disabled("https://github.com/quarkusio/quarkus/issues/40410") public void verifyRestEasyReactiveAndClassicResteasyCollisionUserMsg() { QuarkusCliRestService app = cliClient.createApplication("dependencyCollision", defaultWithFixedStream().withExtensions("resteasy", "rest"));