tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: AJP-APR failures on Tomcat 7.0.16 with ISAPI Redirector 1.2.32
Date Tue, 23 Aug 2011 20:45:45 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Konstantin,

On 8/23/2011 4:02 PM, Konstantin Prei├čer wrote:
> I see that you changed the flush() method in the decorator class to
>  pass flush() calls to the underlying stream as long as the stream
> is set to be "active".
> 
> The reason that I didn't make this call-through was because it
> seems that flush() is the only method called by the ImageIO (when
> the Image Writer is garbage collected), and by preventing any 
> pass-through of flush(), no errors can occur.
> 
> When flush() of the decorator class passes its call to the original
>  stream as long as it's active, there may be a race condition
> between the request processing thread of the Servlet and the GC
> thread which collects the Image Writer, which possibly (but highly
> unlikely) could cause a flush() call (from GC thread) on the
> already closed stream, even if the "isActive" flag is volatile
> (please correct me if I'm wrong - I'm not a expert in how GC is
> working).

I added the flush() pass-through in case you actually wanted to flush
the stream. It seems reasonable that you might want to flush the
buffer at some point, and turning flush() into a no-op didn't seem
like a good idea.

I would expect the image writer to be available for GC after the
request was processed, but I guess the request could have operations
after the ImageIO is actually done and you're right: the GC could
kick-in virtually at any time. If you use your wrapper class as a
fire-and-forget kind of thing while maintaining the original reference
to the OutputStream, I suppose you still have complete control over
flushing that underlying stream.

> Also, it seems that ImageIO is calling flush() a few times while 
> writing an image, and I wanted to avoid the unnecessary flush() 
> calls. ;-)

That's a different story :)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5UEXkACgkQ9CaO5/Lv0PCiNQCgu1foU5uwo63iExja+Wf+WPys
8iIAoJRaIucq9losxjKp0kkhUs6ycZYj
=HDoE
-----END PGP SIGNATURE-----

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


Mime
View raw message