Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B2006CC7F for ; Sun, 11 Jan 2015 05:32:33 +0000 (UTC) Received: (qmail 51759 invoked by uid 500); 11 Jan 2015 05:32:34 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 51665 invoked by uid 500); 11 Jan 2015 05:32:34 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 51654 invoked by uid 99); 11 Jan 2015 05:32:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jan 2015 05:32:34 +0000 Date: Sun, 11 Jan 2015 05:32:34 +0000 (UTC) From: "Stefan Bodewig (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COMPRESS-297) Cleaning up unclosed ZipFile for archive MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COMPRESS-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14272817#comment-14272817 ] Stefan Bodewig commented on COMPRESS-297: ----------------------------------------- True, thanks! svn revision 1650873 > Cleaning up unclosed ZipFile for archive > ---------------------------------------- > > Key: COMPRESS-297 > URL: https://issues.apache.org/jira/browse/COMPRESS-297 > Project: Commons Compress > Issue Type: Bug > Components: Archivers > Affects Versions: 1.8.1 > Environment: Windows 7 64-bit > Reporter: Andrew Liu > Priority: Minor > Fix For: 1.10 > > > If you try to create a ZipFile from a non-existent file, then it throws a FileNotFoundException, which is fine. The problem is that the constructor appears to leave behind objects that the caller cannot close. So, later on when the garbage collector runs, a message is printed to stdout that says "Cleaning up unclosed ZipFile for archive". Here is a failing unit test: > {code:title=TCommonCompressZipFileConstructor.java|borderStyle=solid} > import org.apache.commons.compress.archivers.zip.ZipFile; > import org.junit.Test; > import java.io.File; > import java.io.IOException; > public final class TCommonCompressZipFileConstructor { > @Test > public void constructorThatThrowsExceptionLeavesBehindObjects() { > final File file = new File(""); > try { > new ZipFile(file); > } catch (final IOException e) { > e.printStackTrace(); > System.gc(); > } > } > } > {code} > And here is the test output: > {color:red} > java.io.FileNotFoundException: > at java.io.RandomAccessFile.open(Native Method) > at java.io.RandomAccessFile.(RandomAccessFile.java:241) > at org.apache.commons.compress.archivers.zip.ZipFile.(ZipFile.java:213) > at org.apache.commons.compress.archivers.zip.ZipFile.(ZipFile.java:192) > at org.apache.commons.compress.archivers.zip.ZipFile.(ZipFile.java:153) > at com.mathworks.mlwidgets.explorer.unittest.TCommonCompressZipFileConstructor.constructorThatThrowsExceptionLeavesBehindObjects(TCommonCompressZipFileConstructor.java:14) > ... > com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) > *Cleaning up unclosed ZipFile for archive L:\IntelliJ projects\foo* > {color} -- This message was sent by Atlassian JIRA (v6.3.4#6332)