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

Asynchronous resource methods returning CompletionStage need access to context data

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 3.6.0.Final, 4.0.0.Beta4
    • 4.0.0.Beta1
    • None
    • None

    Description

      Given resource method

            @GET
            @Path("test")
            @Produces("text/plain")
            public CompletionStage<String> text(@Context HttpRequest req) {
               System.out.println("application (inline): " + ResteasyProviderFactory.getContextData(Application.class));
               CompletableFuture<String> cs = new CompletableFuture<>();
               ExecutorService executor = Executors.newSingleThreadExecutor();
               executor.submit(
                     new Runnable() {
                        public void run() {
                           System.out.println("application (async): " + ResteasyProviderFactory.getContextData(Application.class));
                           cs.complete("hello");
                        }
                     });
               return cs;
            }
      

      the output will be something like

      application (inline): org.jboss.resteasy.experiment.undertow.TestCompletionStage$TestApp@72d370fa
      application (async): null
      

      Attachments

        Activity

          People

            rsigal@redhat.com Ronald Sigal
            rsigal@redhat.com Ronald Sigal
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: