tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 51432] New: NullPointerException happens when it costs more time on async processisng than async timeout value
Date Sat, 25 Jun 2011 03:18:20 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=51432

             Bug #: 51432
           Summary: NullPointerException happens when it costs more time
                    on async processisng than async timeout value
           Product: Tomcat 7
           Version: 7.0.16
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: zhh200910@gmail.com
    Classification: Unclassified


In the example "examples\WEB-INF\classes\async\Async1.java",
if we change some value to let the sleeping time of the AsyncThread greater
than async timeout value, there will be a NullPointerException.
Please see the detailed information as the following:

java code:
====================================================================
    protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
        final AsyncContext actx = req.startAsync();
        actx.setTimeout(8*1000);
        Runnable run = new Runnable() {
            @Override
            public void run() {
                try {
                    String path = "/jsp/async/async1.jsp";
                    Thread.currentThread().setName("Async1-Thread");
                    log.info("Putting AsyncThread to sleep");
                    Thread.sleep(12*1000);
                    log.info("Dispatching to "+path);
                    actx.dispatch(path);
                }catch (InterruptedException x) {
                    log.error("Async1",x);
                }catch (IllegalStateException x) {
                    log.error("Async1",x);
                }
            }
        };
        Thread t = new Thread(run);
        t.start();
    }


error:
====================================================================
2011-6-25 10:32:11 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
2011-6-25 10:32:11 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
2011-6-25 10:32:11 org.apache.catalina.startup.Catalina start
信息: Server startup in 497 ms
2011-6-25 10:32:14 async.Async1$1 run
信息: Putting AsyncThread to sleep
2011-6-25 10:32:26 async.Async1$1 run
信息: Dispatching to /jsp/async/async1.jsp
Exception in thread "Async1-Thread" java.lang.NullPointerException
        at
org.apache.catalina.connector.Request.getServletContext(Request.java:1606)
        at
org.apache.catalina.core.AsyncContextImpl.dispatch(AsyncContextImpl.java:138)
        at async.Async1$1.run(Async1.java:49)
        at java.lang.Thread.run(Thread.java:619)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message