You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2009/03/26 16:33:21 UTC

svn commit: r758686 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java

Author: sebb
Date: Thu Mar 26 15:33:09 2009
New Revision: 758686

URL: http://svn.apache.org/viewvc?rev=758686&view=rev
Log:
Make format final - there is then no need to synch. on the field

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=758686&r1=758685&r2=758686&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:33:09 2009
@@ -64,7 +64,7 @@
 
     private boolean finished;
 
-    private short entryFormat = FORMAT_NEW;
+    private final short entryFormat;
 
     private final HashMap names = new HashMap();
 
@@ -84,7 +84,17 @@
      */
     public CpioArchiveOutputStream(final OutputStream out, final short format) {
         this.out = new FilterOutputStream(out);
-        setFormat(format);
+        switch (format) {
+        case FORMAT_NEW:
+        case FORMAT_NEW_CRC:
+        case FORMAT_OLD_ASCII:
+        case FORMAT_OLD_BINARY:
+            break;
+        default:
+            throw new IllegalArgumentException("Unknown format: "+format);
+        
+        }
+        this.entryFormat = format;
     }
 
     /**
@@ -111,29 +121,6 @@
     }
 
     /**
-     * Set a default header format. This will be used if no format is defined in
-     * the cpioEntry given to putNextEntry().
-     * 
-     * @param format
-     *            A CPIO format
-     */
-    private void setFormat(final short format) {
-        switch (format) {
-        case FORMAT_NEW:
-        case FORMAT_NEW_CRC:
-        case FORMAT_OLD_ASCII:
-        case FORMAT_OLD_BINARY:
-            break;
-        default:
-            throw new IllegalArgumentException("Unknown header type");
-
-        }
-        synchronized (this) {
-            this.entryFormat = format;
-        }
-    }
-
-    /**
      * Begins writing a new CPIO file entry and positions the stream to the
      * start of the entry data. Closes the current entry if still active. The
      * current time will be used if the entry has no set modification time and