From 4a03860c2f4dab8a169bf6968e23d91795d42f55 Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Tue, 5 Dec 2006 23:57:57 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@482831 13f79535-47bb-0310-9956-ffa450edef68 --- .../lib/meta/ZipFileMetaDataIterator.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java index 7390a0c2b..dc1c76c73 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java @@ -20,6 +20,7 @@ import java.io.File; 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 @@ public class ZipFileMetaDataIterator 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 class ZipFileMetaDataIterator */ 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 @@ public class ZipFileMetaDataIterator _file = file; _filter = filter; _entries = (file == null) ? null : file.entries(); - _close = true; } public boolean hasNext() throws IOException { @@ -97,11 +101,11 @@ public class ZipFileMetaDataIterator } public void close() { - if (_close) - try { - _file.close(); - } catch (IOException ioe) { - } + try { + if (_file != null) + _file.close(); + } catch (IOException ioe) { + } } //////////////////////////////////////////