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
This commit is contained in:
Pinaki Poddar 2006-12-05 23:57:57 +00:00
parent ee33aa7af3
commit 4a03860c2f
1 changed files with 13 additions and 9 deletions

View File

@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.net.URLConnection;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
@ -37,7 +38,6 @@ public class ZipFileMetaDataIterator
private final ZipFile _file; private final ZipFile _file;
private final MetaDataFilter _filter; private final MetaDataFilter _filter;
private final Enumeration _entries; private final Enumeration _entries;
private final boolean _close;
private ZipEntry _entry = null; private ZipEntry _entry = null;
private ZipEntry _last = null; private ZipEntry _last = null;
@ -46,10 +46,15 @@ public class ZipFileMetaDataIterator
*/ */
public ZipFileMetaDataIterator(URL url, MetaDataFilter filter) public ZipFileMetaDataIterator(URL url, MetaDataFilter filter)
throws IOException { 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; _filter = filter;
_entries = (_file == null) ? null : _file.entries(); _entries = (_file == null) ? null : _file.entries();
_close = false;
} }
/** /**
@ -59,7 +64,6 @@ public class ZipFileMetaDataIterator
_file = file; _file = file;
_filter = filter; _filter = filter;
_entries = (file == null) ? null : file.entries(); _entries = (file == null) ? null : file.entries();
_close = true;
} }
public boolean hasNext() throws IOException { public boolean hasNext() throws IOException {
@ -97,11 +101,11 @@ public class ZipFileMetaDataIterator
} }
public void close() { public void close() {
if (_close) try {
try { if (_file != null)
_file.close(); _file.close();
} catch (IOException ioe) { } catch (IOException ioe) {
} }
} }
////////////////////////////////////////// //////////////////////////////////////////