On Aug 7, 2013, at 1:36 PM, Mark Thomas <ma...@apache.org> wrote: > On 07/08/2013 17:14, Daniel Mikusa wrote: >> I have a questions regarding the Non Blocking API introduced in Tomcat 8. >> >> I'm looking at the TestNonBlockingAPI test as an example, specifically the >> NBReadServlet class. >> >> @WebServlet(asyncSupported = true) >> public class NBReadServlet extends TesterServlet { >> private static final long serialVersionUID = 1L; >> public volatile TestReadListener listener; >> @Override >> protected void service(HttpServletRequest req, HttpServletResponse resp) >> throws ServletException, IOException { >> // step 1 - start async >> AsyncContext actx = req.startAsync(); >> actx.setTimeout(Long.MAX_VALUE); >> actx.addListener(new AsyncListener() { >> // removed for brevity >> }); >> // step 2 - notify on read >> ServletInputStream in = req.getInputStream(); >> listener = new TestReadListener(actx); >> in.setReadListener(listener); >> >> listener.onDataAvailable(); >> } >> } >> >> My question is why does the test call "listener.onDataAvailable()" at the >> end? >> >> In regards to the "onDataAvailable()" method, Section 3.7 of the spec says… >> >> "The onDataAvailable method is invoked on the ReadListener when data is >> available to read from the incoming request stream. The container will >> invoke the method the first time when data is available to read. The >> container will subsequently invoke the onDataAvailable method if and only if >> isReady method on ServletInputStream, described below, returns false." >> >> ...which leads me to believe that the container should be calling >> onDataAvailable and not the servlet. >> >> As a side note, my test works if I call "onDataAvailable()" from my test >> servlet. Otherwise it fails and times out. > > I think you may have a bug there. Please could you create a Bugzilla > entry for it.
Done. https://issues.apache.org/bugzilla/show_bug.cgi?id=55381 Thanks Dan > > Cheers, > > Mark > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org