Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1996

RequestLimit active-request leak caused by reading data through InputStream in user-defined thread pool when using async servlet

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Blocker Blocker
    • 2.3.7.Final
    • 2.2.12.Final
    • Core
    • None
    • Hide

      1.A simple spring framework web app;

      2.Use async controller to handle request;

      3.Create a runnable job, use request.getInputStream to read data in its run method, then submit this job to user-defined thread pool;

      4.Deploy the app and send post request to corresponding resource;

      5.Use jboss-cli.sh to connect to server and monitor the value active-request of subsystem=request-controller. Then you may find the value is accumulated but do not decrease. The problem may not occur right away but after a while.

       

      My code is like this:

      @PostMapping("/doAsyncNormal")
      public DeferredResult<ResponseEntity<String>> doAsyncNormal(HttpServletRequest request) {
              System.out.println("doAsyncNormal");
              final DeferredResult<ResponseEntity<String>> result = new DeferredResult<>();
              asyncExecutor.execute(() -> {
                  try

      {                 String body = IOUtils.toString(request.getInputStream(), "utf-8");                 System.out.println("request body: " + body);                 Thread.sleep(20);                 result.setResult(new ResponseEntity<>("ok", HttpStatus.OK));             }

      catch (Throwable e)

      {                 e.printStackTrace();                 result.setResult(new ResponseEntity<>("error", HttpStatus.INTERNAL_SERVER_ERROR));             }

              });
              return result;
      }

      Show
      1.A simple spring framework web app; 2.Use async controller to handle request; 3.Create a runnable job, use request.getInputStream to read data in its run method, then submit this job to user-defined thread pool; 4.Deploy the app and send post request to corresponding resource; 5.Use jboss-cli.sh to connect to server and monitor the value active-request of subsystem=request-controller. Then you may find the value is accumulated but do not decrease. The problem may not occur right away but after a while.   My code is like this: @PostMapping("/doAsyncNormal") public DeferredResult<ResponseEntity<String>> doAsyncNormal(HttpServletRequest request) {         System.out.println("doAsyncNormal");         final DeferredResult<ResponseEntity<String>> result = new DeferredResult<>();         asyncExecutor.execute(() -> {             try {                 String body = IOUtils.toString(request.getInputStream(), "utf-8");                 System.out.println("request body: " + body);                 Thread.sleep(20);                 result.setResult(new ResponseEntity<>("ok", HttpStatus.OK));             } catch (Throwable e) {                 e.printStackTrace();                 result.setResult(new ResponseEntity<>("error", HttpStatus.INTERNAL_SERVER_ERROR));             }         });         return result; }
    • Release Notes

      1. leak-reproduce.war
        5.43 MB
        kaifei tian

            jaslee@redhat.com Jason Lee
            tiankaifei0108@163.com kaifei tian (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: