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

use Response from RestClient for direct return in api resource broken in 2.5.0 final (but work in 2.4.0 final) #21818

Closed
Fabrice-Deshayes-aka-Xtream opened this issue Nov 30, 2021 · 1 comment
Labels
kind/bug Something isn't working triage/duplicate This issue or pull request already exists

Comments

@Fabrice-Deshayes-aka-Xtream
Copy link

Fabrice-Deshayes-aka-Xtream commented Nov 30, 2021

Describe the bug

My application is a kind of proxy.
It exposes an api, who get its response for another enabler which is requested using RestClient.

Here is the rest client

@Path("/api/v1/supervision")
@RegisterRestClient
public interface ProxyService {
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("/order")
	Response getOrders(
			@HeaderParam(X_OAPI_API_KEY) String apiKey,
			@QueryParam("page") int page,
			@QueryParam("size") int size,
			@QueryParam("filter") String filter
	);
}

Here is the api resource

@Path("/api/v1/supervision")
public class ProxyResources {

	@Inject
	@RestClient
	ProxyService proxyService;

	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("/order/")
	public Response getOrders(
			@HeaderParam(X_OAPI_API_KEY) String apiKey,
			@QueryParam("page") int page,
			@QueryParam("size") int size,
			@QueryParam("filter") String filter) {
		return proxyService.getOrders(apiKey, page, size, filter);
	}
}

Expected behavior

Until quarkus 2.4.0 final, all is working. The restclient get a Response, which is used as the api resource response. The json body and http status are preserved between the restclient and api resource layers.

Actual behavior

After switching to 2.5.0 final, the json response body is corrupted. The beginning of the body is truncated, the end also. The browser seems to stay in progress waiting for a full json response which never come.

We try to bypass the problem by rewriting the Response on the api resource class like this, but it doesn't work

return Response.fromResponse(proxyService.getOrders(apiKey, page, size, filter)).build();

We try to bypass the problem by rewriting the Response on the api resource class like this, and it works

Response response = proxyService.getOrders(apiKey, page, size, filter);
String jsonRead = IOUtils.toString((InputStream) response.getEntity(), Charset.defaultCharset());
return Response.status(response.getStatus()).entity(jsonRead).build();

How to Reproduce?

The problem occurs with quarkus 2.5.0 final, without graalvm (and also with graalvm native version).
It seems that the mechanism which create a Response from another Response has an issue.

Output of uname -a or ver

Linux xtream-pc 5.10.79-1-MANJARO #1 SMP PREEMPT Fri Nov 12 20:26:09 UTC 2021 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.13" 2021-10-19 OpenJDK Runtime Environment (build 11.0.13+8) OpenJDK 64-Bit Server VM (build 11.0.13+8, mixed mode)

GraalVM version (if different from Java)

issue occurs without graalvm

Quarkus version or git rev

2.5.0 final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.3

Additional information

No response

@Fabrice-Deshayes-aka-Xtream Fabrice-Deshayes-aka-Xtream added the kind/bug Something isn't working label Nov 30, 2021
@geoand
Copy link
Contributor

geoand commented Nov 30, 2021

I am pretty sure this is the same problem as #21602.

So I am going to close this as it's fixed and the fixed will be available in 2.5.1.Final. When that comes out, please try it again and if the problem is not solved, please comment on the issue (and attach a project that exhibits the problematic behavior)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants