Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Reactive Rest Client closing connections after server failures" #29674

Merged
merged 1 commit into from Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,10 +1,7 @@
package io.quarkus.rest.client.reactive;

import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

import java.time.Duration;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -75,23 +72,4 @@ void shouldMapQueryParamsWithSpecialCharacters() {
assertThat(map.get("p5")).isEqualTo("5");
assertThat(map.get("p6")).isEqualTo("6");
}

/**
* Test to reproduce https://github.com/quarkusio/quarkus/issues/28818.
*/
@Test
void shouldCloseConnectionsWhenFailures() {
// It's using 30 seconds because it's the default timeout to release connections. This timeout should not be taken into
// account when there are failures, and we should be able to call 3 times to the service without waiting.
await().atMost(Duration.ofSeconds(30))
.until(() -> {
for (int call = 0; call < 3; call++) {
given()
.when().get("/hello/callClientForImageInfo")
.then()
.statusCode(500);
}
return true;
});
}
}
Expand Up @@ -4,7 +4,6 @@
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
Expand All @@ -24,10 +23,4 @@ public interface HelloClient2 {
@GET
@Path("delay")
Uni<String> delay();

@POST
@Path("/imageInfo")
@Consumes("image/gif")
@Produces(MediaType.TEXT_PLAIN)
String imageInfo(byte[] imageFile);
}
Expand Up @@ -78,23 +78,4 @@ public Uni<String> delay() {
return Uni.createFrom().item("Hello")
.onItem().delayIt().by(Duration.ofMillis(500));
}

@Path("callClientForImageInfo")
@GET
public String callClientForImageInfo() {
int size = 1024 * 1024 * 5;

byte[] buffer = new byte[size];

//Should provoke 415 Unsupported Media Type
return client2.imageInfo(buffer);
}

@POST
@Consumes({ "image/jpeg", "image/png" })
@Path("/imageInfo")
@Produces(MediaType.TEXT_PLAIN)
public String imageInfo(byte[] imageFile) {
throw new IllegalStateException("This method should never be invoked");
}
}
Expand Up @@ -20,7 +20,6 @@
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Variant;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -244,11 +243,6 @@ public void handle(HttpClientResponse clientResponse) {
}
}

if (Response.Status.Family.familyOf(status) != Response.Status.Family.SUCCESSFUL) {
httpClientRequest.connection().close();
requestContext.resume();
}

if (isResponseMultipart(requestContext)) {
QuarkusMultipartResponseDecoder multipartDecoder = new QuarkusMultipartResponseDecoder(
clientResponse);
Expand Down Expand Up @@ -372,16 +366,17 @@ public void handle(Buffer buffer) {
requestContext.resume(t);
}
}
}).onFailure(new Handler<>() {
@Override
public void handle(Throwable failure) {
if (failure instanceof IOException) {
requestContext.resume(new ProcessingException(failure));
} else {
requestContext.resume(failure);
}
}
});
})
.onFailure(new Handler<>() {
@Override
public void handle(Throwable failure) {
if (failure instanceof IOException) {
requestContext.resume(new ProcessingException(failure));
} else {
requestContext.resume(failure);
}
}
});
}

private boolean isResponseMultipart(RestClientRequestContext requestContext) {
Expand Down