Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2180

MP Rest client don't work correctly with CompletionStage and RX data types

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 4.0.0.CR1, 3.7.0.Final
    • 4.0.0.Beta7, 3.6.3.Final
    • None
    • None

    Description

      MP Rest client don't work correctly with CompletionStage and RX data types. Client application freezes.

      Example
      REST API:

      @Path("/")
      public interface RxTestInterface {
          @GET
          @Path("normal")
          Single<String> normalSingle();
      
          @GET
          @Path("normal")
          String normalString();
      
          @GET
          @Path("normal")
          CompletionStage<String> normalCs();
      }
      

      End-point:

      @Path("/")
      public class Resource {
          @GET
          @Path("normal")
          public String normal() {
              return "resteasy";
          }
      }
      

      Client code (proxy works correctly):

      public class App {
          public static void main(String[] args) throws Exception {
              ResteasyClient client = (ResteasyClient) ClientBuilder.newBuilder().build();
              RxTestInterface proxy = client.target("http://127.0.0.1:8080/jaxrs-wf").proxy(RxTestInterface.class);
              CompletionStage<String> cs = proxy.normalCs();
              System.out.println(cs.toCompletableFuture().get());
              Single<String> single = proxy.normalSingle();
              single.subscribe((String s) -> {
                  System.out.println(s);
              });
              client.close();
          }
      }
      

      Client code (MP without CompletionStage and RX works correctly):

      public class App {
          public static void main(String[] args) throws Exception {
              RxTestInterface mpRestClient = MicroprofileClientBuilderResolver.instance()
                      .newBuilder()
                      .baseUrl(new URL("http://127.0.0.1:8080/jaxrs-wf"))
                      .build(RxTestInterface.class);
              String s = mpRestClient.normalString();
              System.out.println(s);
          }
      }
      

      Client code (MP with CompletionStage or RX freezes - client application never ends):

      public class App {
          public static void main(String[] args) throws Exception {
              RxTestInterface mpRestClient = MicroprofileClientBuilderResolver.instance()
                      .newBuilder()
                      .baseUrl(new URL("http://127.0.0.1:8080/jaxrs-wf"))
                      .build(RxTestInterface.class);
              CompletionStage<String> cs = mpRestClient.normalCs();
              System.out.println(cs.toCompletableFuture().get());
              Single<String> single = mpRestClient.normalSingle();
              single.subscribe((String s) -> {
                  System.out.println(s);
              });
          }
      }
      

      cc rsigal@redhat.com, rhn-support-asoldano

      Attachments

        Activity

          People

            rhn-support-asoldano Alessio Soldano
            mkopecky@redhat.com Marek Kopecky
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: