openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r482831 - /incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java
Date Tue, 05 Dec 2006 23:58:00 GMT
Author: ppoddar
Date: Tue Dec  5 15:57:57 2006
New Revision: 482831

URL: http://svn.apache.org/viewvc?view=rev&rev=482831
Log:
Not using the cached version of zip file. 
For deploy-undeploy-redeply, the iterator was holding stale reference
to the cached zip content. The 'close' flag is no more required,
the zip file is closed as dictated by the user of the iterator.
  

Modified:
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java?view=diff&rev=482831&r1=482830&r2=482831
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java
Tue Dec  5 15:57:57 2006
@@ -20,6 +20,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.Enumeration;
 import java.util.NoSuchElementException;
 import java.util.zip.ZipEntry;
@@ -37,7 +38,6 @@
     private final ZipFile _file;
     private final MetaDataFilter _filter;
     private final Enumeration _entries;
-    private final boolean _close;
     private ZipEntry _entry = null;
     private ZipEntry _last = null;
 
@@ -46,10 +46,15 @@
      */
     public ZipFileMetaDataIterator(URL url, MetaDataFilter filter)
         throws IOException {
-        _file = (url == null) ? null : (ZipFile) url.getContent();
+        if (url == null) {
+            _file = null;
+        } else {
+            URLConnection con = url.openConnection();
+            con.setDefaultUseCaches(false);
+            _file = (ZipFile) con.getContent();
+        }
         _filter = filter;
         _entries = (_file == null) ? null : _file.entries();
-        _close = false;
     }
 
     /**
@@ -59,7 +64,6 @@
         _file = file;
         _filter = filter;
         _entries = (file == null) ? null : file.entries();
-        _close = true;
     }
 
     public boolean hasNext() throws IOException {
@@ -97,11 +101,11 @@
     }
 
     public void close() {
-        if (_close)
-            try {
-                _file.close();
-            } catch (IOException ioe) {
-            }
+        try {
+           if (_file != null)
+               _file.close();
+        } catch (IOException ioe) {
+        }
     }
 
     //////////////////////////////////////////



Mime
View raw message