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

If ServletInputStream readListener onError resumes exception, server returns HTTP 200

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 3.6.1.SP2, 3.6.2.Final, 4.0.0.Beta6
    • 3.6.1.Final
    • None
    • None

      If ServletInputStream readListener onError resumes exception, server returns HTTP 200

      Priority of this jira is blocker, because this is a regression against RESTEasy 3.5.1 and RESTEasy 3.0.24 (used in WF11)

      see this example:

      @Path("")
      public class ResourceInfoInjectionResource {
          @Context
          private HttpServletRequest request;
      
          @POST
          @Path("a")
          public void a(@Suspended final AsyncResponse async) throws IOException {
              final ServletInputStream inputStream = request.getInputStream();
      
              inputStream.setReadListener(new ReadListener() {
                  @Override
                  public void onDataAvailable() throws IOException {
                      throw new java.lang.IllegalStateException("a exception");
                  }
      
                  @Override
                  public void onAllDataRead() throws IOException {
                  }
      
                  @Override
                  public void onError(Throwable t) {
                      async.resume(t);
                  }
              });
          }
      
          @GET
          @Path("/b")
          public void b(@Suspended final AsyncResponse response) {
              new Thread() {
                  public void run() {
                      try {
                          Thread.sleep(5000);
                          response.resume(new IllegalStateException("b exception"));
                      } catch (Exception e) {
                          throw new RuntimeException(e);
                      }
                  }
              }.start();
          }
      }
      

      "b" end-point works correctly (returns 500), "a" end-point doesn't (returns 200)

            rpelisse@redhat.com Romain Pelisse
            mkopecky@redhat.com Marek Kopecky
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: