Olaf, The bug has been already fixed no that long ago. Thanks for pointing it out, anyways, as it made me think that the code should probably be even more protective:
protected void sendData(OutputStream out) throws IOException { LOG.trace("enter sendData(OutputStream out)"); if (lengthOfData() == 0) { // this file contains no data, so there is nothing to send. // we don't want to create a zero length buffer as this will // cause an infinite loop when reading. LOG.debug("No data to send."); return; } byte[] tmp = new byte[4096]; InputStream instream = source.createInputStream(); try { int len; while ((len = instream.read(tmp)) >= 0) { out.write(tmp, 0, len); } } finally { // we're done with the stream, close it instream.close(); } } Cheers Oleg On Sat, 2003-03-15 at 17:40, [EMAIL PROTECTED] wrote: > I send a file on the harddisk using class "FilePart" and everything works > fine. > But it is just a temporary file which should be deleted afterwards sending > it, but File.delete() fails and the file remains on the disk (based on > alpha 3). As far as I found out, the method "sendData" creates an > inputStream from the file, but did not close it at any time, so the file is > still locked after sending. So my fix is to close this InputStream after > all data is send (line marked with +). I do not know if this has any side > effects or other problems, but my problem would be fixed. > > What do you think? > > Regards, > Olaf > > > protected void sendData(OutputStream out) throws IOException { > LOG.trace("enter sendData(OutputStream out)"); > if (lengthOfData() == 0) { > > // this file contains no data, so there is nothing to send. > // we don't want to create a zero length buffer as this will > // cause an infinite loop when reading. > LOG.debug("No data to send."); > return; > } > > byte[] tmp = new byte[4096]; > InputStream instream = source.createInputStream(); > > int len; > while ((len = instream.read(tmp)) >= 0) { > out.write(tmp, 0, len); > } > > + instream.close(); > } > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]