commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
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 GMT
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");
 



Mime
View raw message