Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 33610 invoked from network); 13 Feb 2008 10:01:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Feb 2008 10:01:20 -0000 Received: (qmail 54619 invoked by uid 500); 13 Feb 2008 10:01:13 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 54599 invoked by uid 500); 13 Feb 2008 10:01:13 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 54590 invoked by uid 99); 13 Feb 2008 10:01:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Feb 2008 02:01:13 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Feb 2008 10:00:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 09ACD1A9832; Wed, 13 Feb 2008 02:00:59 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r627335 - /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java Date: Wed, 13 Feb 2008 10:00:58 -0000 To: commits@harmony.apache.org From: sjanuary@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080213100059.09ACD1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sjanuary Date: Wed Feb 13 02:00:56 2008 New Revision: 627335 URL: http://svn.apache.org/viewvc?rev=627335&view=rev Log: Partial fix for HARMONY-5489 ([pack200][classlib] java.util.ZipException("No Entries") on unpack close()) Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java?rev=627335&r1=627334&r2=627335&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java (original) +++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java Wed Feb 13 02:00:56 2008 @@ -127,15 +127,15 @@ while((jarEntry = jarInputStream.getNextJarEntry()) != null) { outputStream.putNextEntry(jarEntry); byte[] bytes = new byte[16384]; - int bytesRead = 0; + int bytesRead = jarInputStream.read(bytes); while(bytesRead != -1) { - bytesRead = jarInputStream.read(bytes); outputStream.write(bytes, 0, bytesRead); + bytesRead = jarInputStream.read(bytes); } outputStream.closeEntry(); } } else { - while (inputStream.available() > 0) { + while (available(inputStream)) { Segment segment = new Segment(); segment.setLogLevel(logLevel); segment.setLogStream(logFile != null ? (OutputStream) logFile @@ -144,19 +144,28 @@ segment.overrideDeflateHint(deflateHint); } segment.unpack(inputStream, outputStream); + outputStream.flush(); } } - } catch (Exception e) { + } finally { try { inputStream.close(); - } finally { + } catch (Exception e2) {} + try { outputStream.close(); - } + } catch (Exception e2) {} } if (removePackFile) { File file = new File(inputFileName); file.delete(); } + } + + private boolean available(InputStream inputStream) throws IOException { + inputStream.mark(1); + int check = inputStream.read(); + inputStream.reset(); + return check != -1; } /**