DO NOT REPLY [Bug 40202] - running away tmp files

[email protected] Mon, 4 Jun 2007 09:26:08 -0700 (PDT)
Newsgroups gmane.comp.jakarta.slide.devel
Message-ID <[email protected]>
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40202>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40202





------- Additional Comments From [email protected]  2007-06-04 09:26 -------
The problem is that there is no reference on the temporary file.

To solve the problem, I made a TempFileInputStream (extending FileInputStream)
that delete the file on fileinputStream close method.


The inner class :

    public class TempFileInputStream extends FileInputStream {

    	protected File tmpFile = null;

    	public TempFileInputStream (File file) throws FileNotFoundException {
    		super(file);
    		this.tmpFile = file;
    	}
    	
    	public void close () {
			try {
				super.close();
				tmpFile.delete();
			} catch (IOException e) {
				e.printStackTrace();
			}
  		
    	}
    }

The modification in NodeRevisionContent

            long length = FileHelper.globalBufferCopy(is, os);
---            InputStream bis = new BufferedInputStream(new
FileInputStream(buffer));
---            setContent(bis);
+++            setContent(new TempFileInputStream(buffer));

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.