-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Konstantin,
On 7/14/2011 8:41 AM, eurotrans-Verlag wrote: > An alternative that I could imagine, would be to create a class > (that has a boolean flag) which extends OutputStream, and decorates > another OutputStream that is given to the class in the constructor > (that would be the OutputStream from the servlet's response). This > class would pass all calls to it to the other OutputStream (as long > as the flag is true), and as soon as close() or another special > method is called, it sets the flag to false, which causes all other > methods to do nothing (or throw an IOException). That way, Tomcat's > OutputStream would also be protected from future calls from the > ImageIO. You should also null-out the reference to Tomcat's output stream. This would allow you to "leak" your own decorator objects but not interfere with Tomcat's ability to do it's own object management. Such a class would definitely be useful to post on the Wiki. > However, it seems also a bit strange to me that Tomcat is recycling > OutputStreams, because in my understanding, once an OutputStream is > closed, it should be impossible to do any further write() calls to > it. True, but Tomcat tries to avoid as much memory churn as possible, and re-uses objects whenever possible. You can change this behavior with configuration if you want. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk4u6AQACgkQ9CaO5/Lv0PD6cACfW4BS55+FtwpK3ZonNjOuvfPV v+MAn3iCTpTSI+FOBkgdI9UOZD4YvsM6 =oazD -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org