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

AsyncListener.onComplete() not called if AsyncContext.dispatch() is called

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 9.0.0.CR1
    • 8.2.0.Final
    • Web (Undertow)
    • None
    • Hide

      Sample code in description.

      Show
      Sample code in description.
    • Compatibility/Configuration

      Consider this code:

      protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
      {     
              final AsyncContext asyncContext = req.startAsync();
              asyncContext.addListener(new AsyncListener()
              {
                  @Override
                  public void onComplete(AsyncEvent event) throws IOException
                  {
                      System.out.println("complete");
                  }
      
                  @Override
                  public void onTimeout(AsyncEvent event) throws IOException
                  {
                      System.out.println("timeout");
      
                  }
      
                  @Override
                  public void onError(AsyncEvent event) throws IOException
                  {
                      System.out.println("err");
      
                  }
      
                  @Override
                  public void onStartAsync(AsyncEvent event) throws IOException
                  {
                      System.out.println("start");
                  }
              });
      
              new Thread(new Runnable()
              {
                  @Override
                  public void run()
                  {
                      try
                      {
                          Thread.sleep(2000);
                          asyncContext.dispatch("/path2");
                      } catch (InterruptedException e)
                      {
                          e.printStackTrace();
                      }
                  }
              }).start();
      
          }
      

      When used in Wildfly 8.2.0.final complete will never be printed since onComplete() is not called by Wildfly when asyncContext.dispatch() is used even after path2 has finished executing.

      On all other versions of wildfly, and other app servers like tomcat and jetty, complete will be printed.

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              pdeva Prashant Deva (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: