Author: bodewig Date: Mon Dec 22 16:36:19 2014 New Revision: 1647348 URL: http://svn.apache.org/r1647348 Log: COMPRESS-297 only mark file as non-closed when it can be read
Modified: commons/proper/compress/trunk/src/changes/changes.xml commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Modified: commons/proper/compress/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1647348&r1=1647347&r2=1647348&view=diff ============================================================================== --- commons/proper/compress/trunk/src/changes/changes.xml (original) +++ commons/proper/compress/trunk/src/changes/changes.xml Mon Dec 22 16:36:19 2014 @@ -52,6 +52,11 @@ The <action> type attribute can be add,u of the API that is officially supported. This will break existing code that uses the old package. </action> + <action type="fix" date="2014-12-22" issue="COMPRESS-297"> + ZipFile logs a warning in its finalizer when its constructor + has thrown an exception reading the file - for example if the + file doesn't exist. + </action> </release> <release version="1.9" date="2014-10-09" Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1647348&r1=1647347&r2=1647348&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Mon Dec 22 16:36:19 2014 @@ -134,7 +134,7 @@ public class ZipFile implements Closeabl /** * Whether the file is closed. */ - private boolean closed; + private boolean closed = true; // cached buffers - must only be used locally in the class (COMPRESS-172 - reduce garbage collection) private final byte[] DWORD_BUF = new byte[DWORD]; @@ -218,8 +218,8 @@ public class ZipFile implements Closeabl resolveLocalFileHeaderData(entriesWithoutUTF8Flag); success = true; } finally { + closed = !success; if (!success) { - closed = true; IOUtils.closeQuietly(archive); } }