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 :)
Quarkus team said it was required to extends AutoCloseable in RestClient interfaces so connection is closed automatically.