Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 29390 invoked from network); 30 Mar 2009 15:08:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Mar 2009 15:08:17 -0000 Received: (qmail 56922 invoked by uid 500); 30 Mar 2009 15:08:16 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 56858 invoked by uid 500); 30 Mar 2009 15:08:15 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 56831 invoked by uid 99); 30 Mar 2009 15:08:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Mar 2009 15:08:15 +0000 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.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Mar 2009 15:08:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A809C23888AF; Mon, 30 Mar 2009 15:07:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r760000 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java test/java/org/apache/commons/compress/archivers/ArTestCase.java Date: Mon, 30 Mar 2009 15:07:54 -0000 To: commits@commons.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090330150754.A809C23888AF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bodewig Date: Mon Mar 30 15:07:54 2009 New Revision: 760000 URL: http://svn.apache.org/viewvc?rev=760000&view=rev Log: make closeArchiveEntry a NOP if called repeatedly. This makes ArTestCase fail for all platforms consistently 8-) Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java?rev=760000&r1=759999&r2=760000&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java Mon Mar 30 15:07:54 2009 @@ -35,6 +35,7 @@ private long archiveOffset = 0; private long entryOffset = 0; private ArArchiveEntry prevEntry; + private boolean haveUnclosedEntry = true; public ArArchiveOutputStream( final OutputStream pOut ) { this.out = pOut; @@ -47,10 +48,11 @@ } public void closeArchiveEntry() throws IOException { - if ((entryOffset % 2) != 0) { + if (prevEntry != null && haveUnclosedEntry && (entryOffset % 2) != 0) { out.write('\n'); // Pad byte archiveOffset++; } + haveUnclosedEntry = false; } public void putArchiveEntry( final ArchiveEntry pEntry ) throws IOException { @@ -70,6 +72,7 @@ archiveOffset += writeEntryHeader(pArEntry); entryOffset = 0; + haveUnclosedEntry = true; } private long fill( final long pOffset, final long pNewOffset, final char pFill ) throws IOException { Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java?rev=760000&r1=759999&r2=760000&view=diff ============================================================================== --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Mon Mar 30 15:07:54 2009 @@ -89,10 +89,10 @@ public void testArDelete() throws Exception { final File output = new File(dir, "bla.ar"); + final File file1 = getFile("test1.xml"); + final File file2 = getFile("test2.xml"); { // create - final File file1 = getFile("test1.xml"); - final File file2 = getFile("test2.xml"); final OutputStream out = new FileOutputStream(output); final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("ar", out); @@ -107,7 +107,10 @@ out.close(); } - assertEquals(282, output.length()); + assertEquals(8 + + 60 + file1.length() + (file1.length() % 2) + + 60 + file2.length() + (file2.length() % 2), + output.length()); final File output2 = new File(dir, "bla2.ar");