On Dec 19, 2013, at 8:08 PM, David Bullock <david.bull...@machaira.com.au> 
wrote:

> On 20 December 2013 04:10, Daniel Mikusa <dmik...@gopivotal.com> wrote:
>> When run, you'll see that it processes some of the requests but fails due to 
>> a timeout.  I've not been able to replicate the other exceptions with the 
>> unit test though, so those may be unrelated.
> 
>>    @WebServlet(asyncSupported = true)
>>    public class DataStreamingServlet extends HttpServlet {
> 
>>        @Override
>>        protected void service(HttpServletRequest request, 
>> HttpServletResponse response) throws ServletException, IOException
>>        {
>               ...
>>            DataStreamWriteListener dswl = new 
>> DataStreamWriteListener(asyncContext, blocks);
>>            response.getOutputStream().setWriteListener(dswl);
>>        }
> 
>>        private class DataStreamWriteListener implements WriteListener {
>> 
>>                @Override
>>                        public void onWritePossible() throws IOException {
>>                        ServletOutputStream output = 
>> context.getResponse().getOutputStream();
> 
>> Any thoughts on what's happening here?
> 
> This is a total guess ... getOutputStream() is waiting on a lock it
> will never acquire? 

No, it's non-blocking IO so it wouldn't (definitely shouldn't) wait here.  
Instead it writes until it's told that it cannot write (output.isReady() == 
false) without blocking.  At that point, the container is supposed to call my 
code (onWritePossible) once it can write again.  Unfortunately, once this 
problem starts to occur onWritePossible doesn't get called back.

I did a little more testing and for requests that timeout, it does not appear 
that onWritePossible ever gets called.  I added some logging to the code to 
indicate when it first calls onWritePossible, when it must wait to write more 
data and when it's done writing data.  While the test is warming up and the 
requests are being processed OK, I see all three log statements.  Once the 
problem manifests, new requests do not trigger any logging.  They just timeout 
and continue to timeout until I restart the JVM.

> (Increase the timeout, do a thread-dump).

When I take a thread dump of the code, it just shows all of the threads doing 
nothing.  Increasing timeout doesn't seem to help.  Failures still occur within 
the same timeframe (i.e. same number requests to the server).  The only affect 
is to create a delay between when requests stop being processed and the stack 
trace shows up.

>  What happens if you instead pass the ServletOutputStream to the 
> DataStreamWriteListener's constructor?

Unfortunately nothing.  I still see the issue.

Thanks

Dan

> 
> cheers,
> David.
> 
> ---------------------------------------------------------------------
> 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

Reply via email to