Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2008-10-24 01:21:07 +0000
committerSimon Kaegi2008-10-24 01:21:07 +0000
commit857bcd87abf04f420941e53eead93eafd951f5fa (patch)
tree7993f49893a5cc1148773af5b68c46b4c87226a8
parent672d18244248211df0ae62f2daa239e087035193 (diff)
downloadrt.equinox.bundles-857bcd87abf04f420941e53eead93eafd951f5fa.tar.gz
rt.equinox.bundles-857bcd87abf04f420941e53eead93eafd951f5fa.tar.xz
rt.equinox.bundles-857bcd87abf04f420941e53eead93eafd951f5fa.zip
Bug 190279 [server] [plan] Problems cleaning up when undeploying Servletbrdige WAR (tweaks from Tom)
-rw-r--r--bundles/org.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/CloseableURLClassLoader.java33
1 files changed, 18 insertions, 15 deletions
diff --git a/bundles/org.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/CloseableURLClassLoader.java b/bundles/org.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/CloseableURLClassLoader.java
index e06a912a4..1c9ea01d6 100644
--- a/bundles/org.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/CloseableURLClassLoader.java
+++ b/bundles/org.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/CloseableURLClassLoader.java
@@ -22,15 +22,19 @@ public class CloseableURLClassLoader extends URLClassLoader {
static final String BANG_SLASH = "!/"; //$NON-NLS-1$
static final String JAR = "jar"; //$NON-NLS-1$
+ // @GuardedBy("loaders")
final ArrayList loaders = new ArrayList(); // package private to avoid synthetic access.
+ // @GuardedBy("loaders")
private final ArrayList loaderURLs = new ArrayList(); // note: protected by loaders
+ // @GuardedBy("loaders")
boolean closed = false; // note: protected by loaders, package private to avoid synthetic access.
private final AccessControlContext context;
- private boolean verifyJars;
+ private final boolean verifyJars;
public static class CloseableJarURLConnection extends JarURLConnection {
private final JarFile jarFile;
+ // @GuardedBy("this")
private JarEntry entry;
public CloseableJarURLConnection(URL url, JarFile jarFile) throws MalformedURLException {
@@ -42,15 +46,21 @@ public class CloseableURLClassLoader extends URLClassLoader {
* @throws IOException
* Documented to avoid warning
*/
- public synchronized void connect() throws IOException {
+ public void connect() throws IOException {
+ internalGetEntry();
+ }
+
+ private synchronized JarEntry internalGetEntry() throws IOException {
if (entry != null)
- return;
+ return entry;
entry = jarFile.getJarEntry(getEntryName());
+ if (entry == null)
+ throw new FileNotFoundException(getEntryName());
+ return entry;
}
public InputStream getInputStream() throws IOException {
- connect();
- return jarFile.getInputStream(entry);
+ return jarFile.getInputStream(internalGetEntry());
}
/**
@@ -62,8 +72,7 @@ public class CloseableURLClassLoader extends URLClassLoader {
}
public JarEntry getJarEntry() throws IOException {
- connect();
- return entry;
+ return internalGetEntry();
}
}
@@ -88,23 +97,16 @@ public class CloseableURLClassLoader extends URLClassLoader {
private final Manifest manifest;
private final CloseableJarURLStreamHandler jarURLStreamHandler;
private final String jarFileURLPrefixString;
- private final Collection entries = new HashSet();
public CloseableJarFileLoader(File file, boolean verify) throws IOException {
this.jarFile = new JarFile(file, verify);
this.manifest = jarFile.getManifest();
this.jarURLStreamHandler = new CloseableJarURLStreamHandler(jarFile);
this.jarFileURLPrefixString = file.toURL().toString() + BANG_SLASH;
- Enumeration e = jarFile.entries();
- while (e.hasMoreElements()) {
- JarEntry entry = (JarEntry) e.nextElement();
- if (!entry.isDirectory())
- entries.add(entry.getName());
- }
}
public URL getURL(String name) {
- if (entries.contains(name))
+ if (jarFile.getEntry(name) != null)
try {
return new URL(JAR, null, -1, jarFileURLPrefixString + name, jarURLStreamHandler);
} catch (MalformedURLException e) {
@@ -146,6 +148,7 @@ public class CloseableURLClassLoader extends URLClassLoader {
}
}
+ // @GuardedBy("loaders")
private void safeAddLoader(URL url) {
String path = url.getPath();
File file = new File(path);

Back to the top