Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 6177 invoked from network); 30 Sep 2005 01:37:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Sep 2005 01:37:20 -0000 Received: (qmail 92831 invoked by uid 500); 30 Sep 2005 01:37:14 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 92795 invoked by uid 500); 30 Sep 2005 01:37:14 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 92777 invoked by uid 99); 30 Sep 2005 01:37:14 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Sep 2005 18:37:13 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of robert.moore@openlogic.com designates 216.241.163.226 as permitted sender) Received: from [216.241.163.226] (HELO olsrv1.openlogic.local) (216.241.163.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Sep 2005 18:37:19 -0700 Received: from [192.168.10.101] ([192.168.10.101]) by olsrv1.openlogic.local with Microsoft SMTPSVC(6.0.3790.211); Thu, 29 Sep 2005 19:34:53 -0600 Mime-Version: 1.0 (Apple Message framework v622) Content-Transfer-Encoding: 7bit Message-Id: <33836dce604c36af27b57bdffa554e74@openlogic.com> Content-Type: text/plain; charset=US-ASCII; format=flowed To: commons-user@jakarta.apache.org From: robert moore Subject: VFS FileContent inputStream holding file reference ? Date: Thu, 29 Sep 2005 19:36:52 -0600 X-Mailer: Apple Mail (2.622) X-OriginalArrivalTime: 30 Sep 2005 01:34:53.0234 (UTC) FILETIME=[27ED1120:01C5C55F] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N hello, i am having a problem with a file reference being held by the FileContent inputStream (or something in vfs, i think) such that after accessing the contents of a file (zip in this case) i cannot delete the zip file. here are the details: i have tested this on commons vfs version 1.0 dev and 1.0 RC4 with the same results. i have a zip file that contains one file entry "rodss-2.2\docs10.txt". the file entry is found just fine. but after accessing the entry, i cannot delete the zip file. here is my test code: public class VFSTest { File pkgFile = new File("c:\\docs.zip"); public VFSTest() { boolean found = loadEntryFromZipFile(); if (found) { System.out.println("found entry in zip, now trying to delete zip"); if (pkgFile.delete()) { System.out.println("deleted file"); } else { System.out.println("could not delete file"); } } } public boolean loadEntryFromZipFile() { FileSystemManager fsm; ZipFileObject pkgFileEntry = null; FileContent fc = null; InputStream is = null; boolean fileFound = false; String fileEntryName = "rodss-2.2\\docs10.txt"; try { fsm = VFS.getManager(); if ( fileEntryName != null && fileEntryName.startsWith( "zip:file" ) == false ) { if ( pkgFile == null || pkgFile.exists() == false ) return false; URI uri = pkgFile.toURI(); String zipString = "zip:" + uri.toString() + "!"; fileEntryName = zipString + fileEntryName; } pkgFileEntry = (ZipFileObject) fsm.resolveFile( fileEntryName ); if ( pkgFileEntry != null ) { fc = pkgFileEntry.getContent(); if ( fc != null ) { is = fc.getInputStream(); if ( is != null ) { fileFound = true; } } } else { System.out.println( "file entry does not exist for entry: " + fileEntryName ); } } catch ( FileSystemException e ) { fileFound = false; System.out.println( "Error accessing file in zip: " + e.toString() ); } catch ( Throwable e ) { fileFound = false; System.out.println( "Error accessing file in zip: " + e.toString() ); } finally { try { if (is != null) is.close(); if ( fc != null ) fc.close(); if ( pkgFileEntry != null ) { pkgFileEntry.close(); } is = null; fc = null; pkgFileEntry = null; } catch ( Exception e ) { e.printStackTrace(); } } return fileFound; } public static void main(String[] args) { new VFSTest(); } } sorry about the formatting. when i run this as is, the zip file will not get deleted. if i comment out the lines where i get the inputstream, the file will delete. does anyone know if there is a bug where the inputstream is not getting closed or some other file reference is not cleaned up? or am i doing something wrong? thanks for your help. robert. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org