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

AsyncClientResponseProvider is not used

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • None
    • 4.0.0.Final
    • None
    • None

    Description

      AsyncClientResponseProvider should be able to map any resource method that returns CompletionStage to return some other type but this doesn't seems to be respected when the provider is registered with the client.

      Provider:

      @Provider
      public class DummyAsyncClientResponseProvider implements AsyncClientResponseProvider<String> {
          @Override
          public String fromCompletionStage(CompletionStage<?> completionStage) {
              return "injected response";
          }
      }
      

      Resource:

      @Path("/")
      public class PingResource {
      
          @Context
          private UriInfo uriInfo;
          
          @GET
          @Path("async")
          public String async() {
              Client client = ClientBuilder.newClient();
              client.register(DummyAsyncClientResponseProvider.class);
      
              Response response = client.target(uriInfo.getBaseUriBuilder().path("async-client").build())
                  .request().get();
      
              return response.readEntity(String.class);
          }
      
          @GET
          @Path("async-client")
          public CompletionStage<String> asyncClient() {
              return CompletableFuture.supplyAsync(() -> "original string");
          }
      }
      

      I am not sure whether I use it in a right way so can someone confirm that this is expected to trigger DummyAsyncClientResponseProvider when calling GET /async please?

      Attachments

        Issue Links

          Activity

            People

              rsearls r searls
              mstefank Martin Stefanko
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: