diff options
author | acolyer <acolyer> | 2006-02-03 11:52:01 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2006-02-03 11:52:01 +0000 |
commit | 8933b6a6c18860da97a4c89eb113d44bc67525ad (patch) | |
tree | 6dffb276c63a77c1f3ebeee5f43dddd852026e20 /weaver | |
parent | f856b9d877b394ff0b8b9920b18f36aae26ad23b (diff) | |
download | aspectj-8933b6a6c18860da97a4c89eb113d44bc67525ad.tar.gz aspectj-8933b6a6c18860da97a4c89eb113d44bc67525ad.zip |
Progress on: Bug 126328: IlegalStateException : zip file closed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=126328
closes the loop hole with >1000 jars, and adds some extra sanity checks on potentially closed zip files (tested that the call is cheap) to give better error messages.
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java | 19 |
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); |