aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java b/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java
index b3de2d417..3e0423e15 100644
--- a/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java
+++ b/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java
@@ -242,18 +242,35 @@ public class ClassPathManager {
}
private void ensureOpen() {
- if (zipFile != null) return; // If its not null, the zip is already open
+ if (zipFile != null && openArchives.contains(zipFile)) {
+ if (isReallyOpen()) return;
+ }
try {
if (openArchives.size()>=maxOpenArchives) {
closeSomeArchives(openArchives.size()/10); // Close 10% of those open
}
zipFile = new ZipFile(file);
+ if (!isReallyOpen()) {
+ throw new BCException("Can't open archive: "+file.getName()+" (size() check failed)");
+ }
openArchives.add(zipFile);
} catch (IOException ioe) {
throw new BCException("Can't open archive: "+file.getName(),ioe);
}
}
+ private boolean isReallyOpen() {
+ try {
+ zipFile.size(); // this will fail if the file has been closed for
+ // some reason;
+ return true;
+ } catch (IllegalStateException ex) {
+ // this means the zip file is closed...
+ return false;
+ }
+
+ }
+
public void closeSomeArchives(int n) {
for (int i=n-1;i>=0;i--) {
ZipFile zf = (ZipFile)openArchives.get(i);