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

Async request filters using `suspend`/`resume` on `SuspendableContainerRequestContext` cause 400 BAD REQUEST for async endpoints with `@Suspended` `AsyncResponse`es

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.2.7.Final, 7.0.0.Alpha1
    • 4.7.9.Final, 6.2.5.Final
    • None
    • None
    • Hide
      1. Checkout https://github.com/andrii-rubtsov/resteasy-async-filter-issue-mvp 
      2. Amend host/port in `Server.java` if needed and start the server's main.
      3. Try making the call to async endpoint: `curl 127.0.0.1:9999/resource/async -v`

      Actual result:

      ❯ curl 127.0.0.1:9999/resource/async -v
      *   Trying 127.0.0.1:9999...
      * Connected to 127.0.0.1 (127.0.0.1) port 9999
      > GET /resource/async HTTP/1.1
      > Host: 127.0.0.1:9999
      > User-Agent: curl/8.3.0
      > Accept: */*
      > 
      < HTTP/1.1 400 Bad Request
      < content-length: 0
      < connection: keep-alive
      < 
      * Connection #0 to host 127.0.0.1 left intact
       

      Expected result:

      Can be achieved by commenting out `AsyncFilter` in RestEasyApplication.java and restarting the server:

      ❯ curl 127.0.0.1:9999/resource/async -v
      *   Trying 127.0.0.1:9999...
      * Connected to 127.0.0.1 (127.0.0.1) port 9999
      > GET /resource/async HTTP/1.1
      > Host: 127.0.0.1:9999
      > User-Agent: curl/8.3.0
      > Accept: */*
      > 
      < HTTP/1.1 200 OK
      < connection: keep-alive
      < Content-Type: text/plain;charset=UTF-8;resteasy-server-has-produces=true
      < transfer-encoding: chunked
      < 
      Async response 0
      * Connection #0 to host 127.0.0.1 left intact
       
      Show
      Checkout https://github.com/andrii-rubtsov/resteasy-async-filter-issue-mvp   Amend host/port in `Server.java` if needed and start the server's main. Try making the call to async endpoint: `curl 127.0.0.1:9999/resource/async -v` Actual result: ❯ curl 127.0.0.1:9999/resource/async -v *   Trying 127.0.0.1:9999... * Connected to 127.0.0.1 (127.0.0.1) port 9999 > GET /resource/async HTTP/1.1 > Host: 127.0.0.1:9999 > User-Agent: curl/8.3.0 > Accept: */* >  < HTTP/1.1 400 Bad Request < content-length: 0 < connection: keep-alive <  * Connection #0 to host 127.0.0.1 left intact Expected result: Can be achieved by commenting out `AsyncFilter` in RestEasyApplication.java and restarting the server: ❯ curl 127.0.0.1:9999/resource/async -v *   Trying 127.0.0.1:9999... * Connected to 127.0.0.1 (127.0.0.1) port 9999 > GET /resource/async HTTP/1.1 > Host: 127.0.0.1:9999 > User-Agent: curl/8.3.0 > Accept: */* >  < HTTP/1.1 200 OK < connection: keep-alive < Content-Type: text/plain;charset=UTF-8;resteasy-server-has-produces= true < transfer-encoding: chunked <  Async response 0 * Connection #0 to host 127.0.0.1 left intact

      From reading the documentation for async filters the one can come to the conclusion that adding async filter should be seamless to the existing endpoints(resources). In particular, existing endpoints with `AsyncResponse` input parameters marked with Jakarta's `@Suspended`should work as expected.

       https://docs.jboss.org/resteasy/docs/6.2.5.Final/userguide/html/ch35.html#d5e2422

      But in reality it turns out that such endpoints will cause 400 BAD REQUEST if the async filter suspends + resumes request before reaching it.

      Please let me know if I understood the advertised (expected) behavior correctly.

      I tested with 4.7.9.Final too, the result was the same.

      In my experiments (see git repo below) the advertised resume/suspend behavior only works correctly for sync endpoints.

              jperkins-rhn James Perkins
              andrii.rubtsov Andrii Rubtsov (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: