Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 79209 invoked from network); 16 Feb 2006 13:19:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Feb 2006 13:19:31 -0000 Received: (qmail 33404 invoked by uid 500); 16 Feb 2006 13:19:26 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 33326 invoked by uid 500); 16 Feb 2006 13:19:24 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 33258 invoked by uid 99); 16 Feb 2006 13:19:24 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2006 05:19:23 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 7E54ADF for ; Thu, 16 Feb 2006 14:19:02 +0100 (CET) Message-ID: <904340262.1140095942486.JavaMail.jira@ajax.apache.org> Date: Thu, 16 Feb 2006 14:19:02 +0100 (CET) From: "Tim Ellison (JIRA)" To: harmony-dev@incubator.apache.org Subject: [jira] Assigned: (HARMONY-97) ZipOutputStream.close() throws IOException if the stream is already closed In-Reply-To: <929193176.1140083159740.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/HARMONY-97?page=all ] Tim Ellison reassigned HARMONY-97: ---------------------------------- Assign To: Tim Ellison > ZipOutputStream.close() throws IOException if the stream is already closed > -------------------------------------------------------------------------- > > Key: HARMONY-97 > URL: http://issues.apache.org/jira/browse/HARMONY-97 > Project: Harmony > Type: Bug > Components: Classlib > Reporter: Svetlana Samoilenko > Assignee: Tim Ellison > > According to 1.5 specification for ?lose() method in interface Closeable: > "Closes this stream and releases any system resources associated with it. > If the stream is already closed then invoking this method has no effect". > Harmony throws IOException if the stream is already closed. > Code to reproduce: > import java.io.*; > import java.util.zip.*; > public class test2 { > public static void main(String args[]) { > ZipOutputStream zos = null; > try { > File f=new File("myFile"); > f.createNewFile(); > f.deleteOnExit(); > FileOutputStream ff=new FileOutputStream(f); > BufferedOutputStream b=new BufferedOutputStream(ff); > zos=new ZipOutputStream(new BufferedOutputStream(b)); > zos.putNextEntry(new ZipEntry("myFile")); > } catch (IOException ee) { > ee.printStackTrace(); > } > try { > zos.close(); > zos.close(); > System.out.println("PASSED"); > } catch (IOException ee) { > System.out.println("FAILED"); > ee.printStackTrace(); > } > } > } > Steps to Reproduce: > 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. > 2. Compile test2.java using BEA 1.4 javac > > javac -d . test2.java > 3. Run java using compatible VM (J9) > > java -showversion test2 > Output: > C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 > java version "1.4.2_04" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) > BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) > PASSED > C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 > (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. > FAILED > java.io.IOException: Stream is closed > at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:157) > at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:66) > at test2.main(test2.java:26) > Suggested fix: > Index: trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java > =================================================================== > --- trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java (revision 378195) > +++ trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java (working copy) > @@ -77,8 +77,7 @@ > */ > public void close() throws IOException { > finish(); > - out.close(); > - out = null; > + out.close(); > } > /** > @@ -165,9 +164,7 @@ > * @exception IOException > * If an error occurs while finishing > */ > - public void finish() throws IOException { > - if (out == null) > - throw new IOException(Msg.getString("K0059")); > + public void finish() throws IOException { > if (cDir == null) > return; > if (entries.size() == 0) > Suggested junit test case: > ------------------------ ZipOutputStreamTest.java ------------------------------------------------- > import junit.framework.*; > import java.util.zip.*; > import java.io.*; > public class ZipOutputStreamTest extends TestCase { > public static void main(String[] args) { > junit.textui.TestRunner.run(ZipOutputStream.class); > } > public void test_close() { > ZipOutputStream zos = null; > try { > File f=new File("myFile"); > f.createNewFile(); > f.deleteOnExit(); > FileOutputStream ff=new FileOutputStream(f); > BufferedOutputStream b=new BufferedOutputStream(ff); > zos=new ZipOutputStream(new BufferedOutputStream(b)); > zos.putNextEntry(new ZipEntry("myFile")); > } catch (IOException ee) { > fail("Unnexpected IOException"); > } > try { > zos.close(); > zos.close(); > } catch (IOException ee) { > fail("Unnexpected IOException"); > } > } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira