Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-10710

DeferredResult timeout and Tomcat IllegalStateException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Works as Designed
    • Affects Version/s: 3.2.3
    • Fix Version/s: None
    • Component/s: Web

      Description

      I'm using Spring 3.2.3 and Tomcat 7.0.41 with the NIO backend. I'm (still) experiencing problems with timeout handling of DeferredResult. (See SPR-10485 for an earlier bug.)

      Consider the following code:

      @Controller
      public class TestController {
      
          @RequestMapping(value="/test")
          @ResponseBody
          public DeferredResult<String> test() {
              return new DeferredResult<String>(50L, "timeout\n");
          }
      
      }
      

      Now, create 100 threads which send this request in a loop: (The "parallel" command here is GNU parallel.)

      yes 'curl --silent http://localhost:8080/test' | parallel -j100
      

      Some of these requests will fail and Tomcat will log the this exception:

      jul 01, 2013 11:42:38 AM org.apache.coyote.AbstractProtocol$AbstractConnectionHandler process
      SEVERE: Error reading request, ignored
      java.lang.IllegalStateException: Calling [asyncPostProcess()] is not valid for a request with Async state [STARTED]
              at org.apache.coyote.AsyncStateMachine.asyncPostProcess(AsyncStateMachine.java:204)
              at org.apache.coyote.AbstractProcessor.asyncPostProcess(AbstractProcessor.java:116)
              at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:593)
              at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1686)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
              at java.lang.Thread.run(Thread.java:724)
      

        Attachments

          Activity

            People

            Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            pdewacht Peter De Wachter
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 25 weeks, 2 days ago