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=34893>. 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=34893 ------- Additional Comments From [EMAIL PROTECTED] 2005-05-13 00:26 ------- I think it's a matter of finalizers. Expand.java creates a ZipFile. An IOException is thrown during the ZipFile constructor when archive.seek() is called with a negative offset in the positionAtCentralDirectory method. The instance variable, archive, is holding a RandomAccessFile object and eventually may be garbage collected. But until then, the file remains open. The zf.close() in Expand.java's finally is irrelevant here because the exception happened during the "zf = new ZipFile..." statement. The fix is to change the ZipFile so it explicitly closes "archive". New constructor: public ZipFile(File f, String encoding) throws IOException { this.encoding = encoding; archive = new RandomAccessFile(f, "r"); try { populateFromCentralDirectory(); resolveLocalFileHeaderData(); } catch (IOException e) { archive.close(); throw e; } } Old constructor (for comparision purposes): public ZipFile(File f, String encoding) throws IOException { this.encoding = encoding; archive = new RandomAccessFile(f, "r"); populateFromCentralDirectory(); resolveLocalFileHeaderData(); } Here's some standalone test code which also exhibits the problem: import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; public class Test { public static void main( String[] args ) { final String fileName = "xxx.zip"; //WORKS RandomAccessFile f2 = null; try { // Touch the file new RandomAccessFile(fileName, "rw").close(); // Perform a seek. This throws an IOException RandomAccessFile f2 = null; f2 = new RandomAccessFile(fileName, "r"); f2.seek(-2); } catch (IOException e) { e.printStackTrace(); /* WORKS try { System.out.println("Explictly closing the file"); f2.close(); } catch (IOException e2) { e2.printStackTrace(); } WORKS */ } final boolean rc = new File(fileName).delete(); System.out.println(rc); } Leave the comments in the code, and the delete() method returns false. Uncomment the WORKS lines (and move the var declaration up) and the delete() method returns true. -- 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. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]