commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1094854 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipFile.java test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
Date Tue, 19 Apr 2011 05:24:59 GMT
Author: bodewig
Date: Tue Apr 19 05:24:58 2011
New Revision: 1094854

URL: http://svn.apache.org/viewvc?rev=1094854&view=rev
Log:
RandomAccessFile.close() doesn't throw any exception when it is closed more than once, so
the guard and synchronization are not needed

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1094854&r1=1094853&r2=1094854&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
Tue Apr 19 05:24:58 2011
@@ -213,11 +213,9 @@ public class ZipFile {
      * Closes the archive.
      * @throws IOException if an error occurs closing the archive.
      */
-    public synchronized void close() throws IOException {
-        if (!closed) {
-            closed = true;
-            archive.close();
-        }
+    public void close() throws IOException {
+        closed = true;
+        archive.close();
     }
 
     /**

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1094854&r1=1094853&r2=1094854&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
Tue Apr 19 05:24:58 2011
@@ -88,6 +88,16 @@ public class ZipFileTest extends TestCas
         assertEntryName(l, 22, "ZipUtil");
     }
 
+    public void testDoubleClose() throws Exception {
+        readOrderTest();
+        zf.close();
+        try {
+            zf.close();
+        } catch (Exception ex) {
+            fail("Caught exception of second close");
+        }
+    }
+
     /*
      * ordertest.zip has been handcrafted.
      *



Mime
View raw message