-
Bug
-
Resolution: Done
-
Minor
-
25.0.0.Final
-
None
-
Workaround Exists
-
If injecting the "ClientProxy" via
T ResteasyWebTarget.proxy(Class<T> var1)
then the caller does not have access on the Client to close it after the call.
Following warning is logged after the call:
(org.jboss.resteasy.client.jaxrs.i18n) RESTEASY004687: Closing a class org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine instance for you. Please close clients yourself.
By the way: Same issue is already reported by Quarkus:
https://github.com/quarkusio/quarkus/issues/10813
https://stackoverflow.com/questions/64137112/quarkus-restclient-close
I'm not sure, if it is Wildfly 25 or Resteasy related. But we had never this issue before.
See examples:
The Resteasy client producer
import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @ApplicationScoped public class ClientProducer { @Produces public Client getClient() { return ClientBuilder.newBuilder() // .register(.......) // .register(.......) .build(); } }
The remote service as interface
import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; @Path("/") public interface EchoService { @GET @Path("/echo") @Produces(MediaType.TEXT_PLAIN) String echo(@QueryParam("name") String name); }
The remote service producer via ResteasyWebTarget.proxy
import javax.enterprise.context.Dependent; import javax.enterprise.context.RequestScoped; import javax.enterprise.inject.Produces; import javax.inject.Inject; import javax.ws.rs.client.Client; import org.jboss.resteasy.client.jaxrs.ResteasyClient; @Dependent public class EchoServiceProducer { @Inject private Client client; @Produces @RequestScoped public EchoService getEchoService(){ return ((ResteasyClient) client).target("https://postman-echo.com/get").proxy(EchoService.class); } }
And a caller, somewhere in the code.
@Inject private EchoService service; public void executeRestCall(){ service.echo("test"); }
- is incorporated by
-
RESTEASY-3079 Add support for inject some context types
- Resolved