Reputation: 151
I would like to know what is the behavior of quarkus when a RestClient is injected through CDI.
Does it close the client automatically in the example below?
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@RegisterRestClient
@RegisterClientHeaders
public interface CarClient {
@GET
@Path("/cars/{id}")
@Timeout(4500L)
Car getCar(@PathParam("id") String id);
}
@Inject
@RestClient
CarClient carClient;
Or Quarkus requires it to extends AutoCloseable like the example below?
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@RegisterRestClient
@RegisterClientHeaders
public interface CarClient extends AutoCloseable {
@GET
@Path("/cars/{id}")
@Timeout(4500L)
Car getCar(@PathParam("id") String id);
}
@Inject
@RestClient
CarClient carClient;
We are getting some warnings and we need to be sure if everything is being closed.
WARN: RESTEASY004687: Closing a class org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine instance for you. Please close clients yourself.
PS: Suggestion for the quarkus team to show in the warning the client with the issue :)
Upvotes: 4
Views: 4219
Reputation: 12787
Actually this is bug. The workaround is to make the client extend Closeable(still present in Quarkus 2.16.1).
Upvotes: 0
Reputation: 658
Per source this engine is a ManualClosing one, see https://github.com/resteasy/Resteasy/blob/main/resteasy-client/src/main/java/org/jboss/resteasy/client/jaxrs/engines/ApacheHttpClient43Engine.java
You should set a breakpoint here : https://github.com/resteasy/Resteasy/blob/main/resteasy-client/src/main/java/org/jboss/resteasy/client/jaxrs/engines/ApacheHttpClient43Engine.java#L37
The key allowClosingHttpClient is set here : https://github.com/resteasy/resteasy/blob/main/resteasy-client/src/main/java/org/jboss/resteasy/client/jaxrs/engines/ManualClosingApacheHttpClient43Engine.java#L163
So if you want to be sure, and understand why this warning happens in your case, you should set these breakpoints
Upvotes: 0
Reputation: 151
Quarkus team said it was required to extends AutoCloseable in RestClient interfaces so connection is closed automatically.
Upvotes: 6