> Do we really need to go around and aggressively clean up these
> InputStreams? Can't we do that in a finalize() method somewhere?

NO!!!!!!  NEVER use finalize(), especially not server-side.

If you need to automatically cleanup resources when they are unused, without
having to call explicit cleanup, use phantom references.  That is why they
exist.  If you don't know how to use phantom references, review the
FileCleaner that I contributed to Commons.

For that matter, why aren't you using Commons?  The very problem (file
uploading) you are dickering with is precisely one that we addressed in
Commons years ago.  The core code is in Commons I/O:

http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/ap
ache/commons/io/

and there are servlet and portlet drivers for it in Commons FileUpload (gee,
need a hint as to what problem the code solves?):

http://svn.apache.org/viewvc/jakarta/commons/proper/fileupload/trunk/src/jav
a/org/apache/commons/fileupload/

Sorry if this comes across as being snarky, but rewriting the wheel is bad
enough;  getting it wrong is worse.

        --- Noel


Reply via email to