Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-15888

RESTEASY004687 client.close()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 27.0.0.Alpha1, 27.0.0.Final
    • 25.0.0.Final
    • REST
    • None
    • Workaround Exists
    • Hide

      Currently we are filtering the warnings in the subsystem:logging

      Show
      Currently we are filtering the warnings in the subsystem:logging

      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");
      } 

        1. ClientProducer.java
          0.4 kB
        2. EchoService.java
          0.4 kB
        3. EchoServiceProducer.java
          0.5 kB
        4. ResourceTest.java
          0.3 kB

            rsigal@redhat.com Ronald Sigal
            juerg.drollinger@six-group.com Jürg Drollinger (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: