You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Wartes <zi...@gmail.com> on 2015/12/02 20:13:04 UTC

No access log line if client aborts

I'm having a problem where requests made to Tomcat that the client aborts
early wind up not producing an access log line. I've reproduced it on
Tomcat 7.0.39 and Tomcat 8.0.28.

The repro case is pretty easy. Just use a browser to make a request to any
application endpoint and then close the browser tab before the request
finishes.

Stepping through the Tomcat source code it's pretty clear why the access
log is skipped in this case. The CoyoteAdapter calls
response.finishResponse() before calling the access log. If the client is
gone, the finishResponse method throws an exception when trying to flush
its output buffer, which causes the access log line to be skipped.

Does anyone have any insight into this problem?

Re: No access log line if client aborts

Posted by Mike Wartes <zi...@gmail.com>.
Hi Chris, thanks for your reply.

Yeah, I'm sure the request made it to Tomcat. The specific way I have
reproduced the problem is by setting a breakpoint on a line in my
application code, making a request in a browser, waiting for the breakpoint
to get hit, closing the browser tab that made the request, and then letting
the code execution resume.

It does occur to me that a fix for this issue might quickly lead into a
feature request because the fact of a client abort is an interesting thing
that it would be nice to put in an access log line. But for now I'm more
concerned with getting the line to show up at all.


On Wed, Dec 2, 2015 at 12:08 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> Mike,
>
> On 12/2/15 2:13 PM, Mike Wartes wrote:
> > I'm having a problem where requests made to Tomcat that the client aborts
> > early wind up not producing an access log line. I've reproduced it on
> > Tomcat 7.0.39 and Tomcat 8.0.28.
> >
> > The repro case is pretty easy. Just use a browser to make a request to
> any
> > application endpoint and then close the browser tab before the request
> > finishes.
>
> Can you confirm whether the request line has been sent to Tomcat at this
> point?
>
> > Stepping through the Tomcat source code it's pretty clear why the access
> > log is skipped in this case. The CoyoteAdapter calls
> > response.finishResponse() before calling the access log. If the client is
> > gone, the finishResponse method throws an exception when trying to flush
> > its output buffer, which causes the access log line to be skipped.
> >
> > Does anyone have any insight into this problem?
>
> Sounds like it would be pretty easy to correct this problem if it's as
> simple as you describe.
>
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: No access log line if client aborts

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Mike,

On 12/2/15 2:13 PM, Mike Wartes wrote:
> I'm having a problem where requests made to Tomcat that the client aborts
> early wind up not producing an access log line. I've reproduced it on
> Tomcat 7.0.39 and Tomcat 8.0.28.
> 
> The repro case is pretty easy. Just use a browser to make a request to any
> application endpoint and then close the browser tab before the request
> finishes.

Can you confirm whether the request line has been sent to Tomcat at this
point?

> Stepping through the Tomcat source code it's pretty clear why the access
> log is skipped in this case. The CoyoteAdapter calls
> response.finishResponse() before calling the access log. If the client is
> gone, the finishResponse method throws an exception when trying to flush
> its output buffer, which causes the access log line to be skipped.
> 
> Does anyone have any insight into this problem?

Sounds like it would be pretty easy to correct this problem if it's as
simple as you describe.

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org