commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r758707 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
Date Thu, 26 Mar 2009 15:58:20 GMT
Author: sebb
Date: Thu Mar 26 15:58:05 2009
New Revision: 758707

URL: http://svn.apache.org/viewvc?rev=758707&view=rev
Log:
Disallow mixed header formats in a single output file

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=758707&r1=758706&r2=758707&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
Thu Mar 26 15:58:05 2009
@@ -64,6 +64,9 @@
 
     private boolean finished;
 
+    /**
+     * See {@link CpioArchiveEntry#setFormat(short)} for possible values.
+     */
     private final short entryFormat;
 
     private final HashMap names = new HashMap();
@@ -142,10 +145,11 @@
             e.setTime(System.currentTimeMillis());
         }
 
-        // TODO what happens if an entry has an other format than the
-        // outputstream?
-        if (e.getFormat() == -1) {
+        final short format = e.getFormat();
+        if (format == -1) {
             e.setFormat(this.entryFormat);
+        } else if (format != this.entryFormat){
+            throw new IOException("Header format: "+format+" does not match existing format:
"+this.entryFormat);
         }
 
         if (this.names.put(e.getName(), e) != null) {



Mime
View raw message