commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1660005 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
Date Sun, 15 Feb 2015 23:09:26 GMT
Author: sebb
Date: Sun Feb 15 23:09:26 2015
New Revision: 1660005

URL: http://svn.apache.org/r1660005
Log:
COMPRESS-302 Restore immutability/thread-safety to ArchiveStreamFactory.

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1660005&r1=1660004&r2=1660005&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sun Feb 15 23:09:26 2015
@@ -54,6 +54,11 @@ breaks backwards compatibility for code
 This also changes the superclass of ZCompressorInputStream.    
 ">
 
+      <action issue="COMPRESS-302" type="fix">
+        Restore immutability/thread-safety to ArchiveStreamFactory.
+        The class is now immutable provided that the method setEntryEncoding is not used.
+        The class is thread-safe.
+      </action>
       <action issue="COMPRESS-303" type="fix">
         Restore immutability/thread-safety to CompressorStreamFactory.
         The class is now immutable provided that the method setDecompressConcatenated is
not used.

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=1660005&r1=1660004&r2=1660005&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
Sun Feb 15 23:09:26 2015
@@ -71,7 +71,7 @@ import org.apache.commons.compress.utils
  * out.close();
  * in.close();
  * </pre>
- * 
+ * @Immutable provided that the deprecated method setEntryEncoding is not used.
  */
 public class ArchiveStreamFactory {
 
@@ -119,9 +119,35 @@ public class ArchiveStreamFactory {
     public static final String SEVEN_Z = "7z";
 
     /**
+     * Entry encoding, null for the platform default.
+     */
+    private final String encoding;
+
+    /**
      * Entry encoding, null for the default.
      */
-    private String entryEncoding = null;
+    private volatile String entryEncoding = null;
+
+    /**
+     * Create an instance using the platform default encoding.
+     */
+    public ArchiveStreamFactory() {
+        this(null);
+    }
+
+    /**
+     * Create an instance using the specified encoding.
+     *
+     * @param encoding the encoding to be used.
+     *
+     * @since 1.10
+     */
+    public ArchiveStreamFactory(String encoding) {
+        super();
+        this.encoding = encoding;
+        // Also set the original field so can continue to use it.
+        this.entryEncoding = encoding;
+    }
 
     /**
      * Returns the encoding to use for arj, zip, dump, cpio and tar
@@ -139,8 +165,16 @@ public class ArchiveStreamFactory {
      * 
      * @param entryEncoding the entry encoding, null uses the default.
      * @since 1.5
+     * @deprecated 1.10 use {@link #ArchiveStreamFactory(String)} to specify the encoding
+     * @throws IllegalStateException if the constructor {@link #ArchiveStreamFactory(String)}

+     * was used to specify the factory encoding.
      */
+    @Deprecated
     public void setEntryEncoding(String entryEncoding) {
+        // Note: this does not detect new ArchiveStreamFactory(null) but that does not set
the encoding anyway
+        if (encoding != null) {
+            throw new IllegalStateException("Cannot overide encoding set by the constructor");
+        }
         this.entryEncoding = entryEncoding;
     }
 



Mime
View raw message