commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1649172 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FileBasedScatterGatherBackingStore.java
Date Sat, 03 Jan 2015 04:58:35 GMT
Author: bodewig
Date: Sat Jan  3 04:58:35 2015
New Revision: 1649172

URL: http://svn.apache.org/r1649172
Log:
allow close to be used even if stream hasn't been closed before

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FileBasedScatterGatherBackingStore.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FileBasedScatterGatherBackingStore.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FileBasedScatterGatherBackingStore.java?rev=1649172&r1=1649171&r2=1649172&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FileBasedScatterGatherBackingStore.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FileBasedScatterGatherBackingStore.java
Sat Jan  3 04:58:35 2015
@@ -32,6 +32,7 @@ import java.io.InputStream;
 public class FileBasedScatterGatherBackingStore implements ScatterGatherBackingStore {
     private final File target;
     private final FileOutputStream os;
+    private boolean closed;
 
     public FileBasedScatterGatherBackingStore(File target) throws FileNotFoundException {
         this.target = target;
@@ -44,7 +45,10 @@ public class FileBasedScatterGatherBacki
 
     @SuppressWarnings("ResultOfMethodCallIgnored")
     public void closeForWriting() throws IOException {
-        os.close();
+        if (!closed) {
+            os.close();
+            closed = true;
+        }
     }
 
     public void writeOut(byte[] data, int offset, int length) throws IOException {
@@ -52,6 +56,7 @@ public class FileBasedScatterGatherBacki
     }
 
     public void close() throws IOException {
+        closeForWriting();
         target.delete();
     }
 }



Mime
View raw message