Improved how Felix ignores non-existent bundle class path entries; now it
tests for existence and removes them if they are invalid.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@464939 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java b/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
index 783e486..4fe902c 100644
--- a/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
+++ b/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
@@ -20,7 +20,7 @@
import java.io.*;
import java.security.cert.X509Certificate;
-import java.util.Map;
+import java.util.*;
import java.util.jar.*;
import org.apache.felix.framework.Logger;
@@ -132,12 +132,12 @@
// Create the bundles class path.
IContent self = new DirectoryContent(m_refDir);
- IContent[] contentPath = new IContent[classPathStrings.length];
+ List contentList = new ArrayList();
for (int i = 0; i < classPathStrings.length; i++)
{
if (classPathStrings[i].equals(FelixConstants.CLASS_PATH_DOT))
{
- contentPath[i] = self;
+ contentList.add(self);
}
else
{
@@ -145,23 +145,27 @@
File file = new File(m_refDir, classPathStrings[i]);
if (BundleCache.getSecureAction().isFileDirectory(file))
{
- contentPath[i] = new DirectoryContent(file);
+ contentList.add(new DirectoryContent(file));
}
else
{
- contentPath[i] = new JarContent(file);
+ // Ignore any entries that do not exist per the spec.
+ if (BundleCache.getSecureAction().fileExists(file))
+ {
+ contentList.add(new JarContent(file));
+ }
}
}
}
// If there is nothing on the class path, then include
// "." by default, as per the spec.
- if (contentPath.length == 0)
+ if (contentList.size() == 0)
{
- contentPath = new IContent[] { self };
+ contentList.add(new IContent[] { self });
}
- return contentPath;
+ return (IContent[]) contentList.toArray(new IContent[contentList.size()]);
}
// TODO: This will need to consider security.
diff --git a/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java b/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
index d383e6e..f9618e3 100644
--- a/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
+++ b/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
@@ -148,12 +148,12 @@
{
bundleJar = BundleCache.getSecureAction().openJAR(m_bundleFile);
IContent self = new JarContent(m_bundleFile);
- IContent[] contentPath = new IContent[classPathStrings.length];
+ List contentList = new ArrayList();
for (int i = 0; i < classPathStrings.length; i++)
{
if (classPathStrings[i].equals(FelixConstants.CLASS_PATH_DOT))
{
- contentPath[i] = self;
+ contentList.add(self);
}
else
{
@@ -162,23 +162,28 @@
ZipEntry entry = bundleJar.getEntry(classPathStrings[i]);
if ((entry != null) && entry.isDirectory())
{
- contentPath[i] = new ContentDirectoryContent(self, classPathStrings[i]);
+ contentList.add(new ContentDirectoryContent(self, classPathStrings[i]));
}
else
{
- contentPath[i] = new JarContent(new File(embedDir, classPathStrings[i]));
+ // Ignore any entries that do not exist per the spec.
+ File extractedJar = new File(embedDir, classPathStrings[i]);
+ if (BundleCache.getSecureAction().fileExists(extractedJar))
+ {
+ contentList.add(new JarContent(extractedJar));
+ }
}
}
}
// If there is nothing on the class path, then include
// "." by default, as per the spec.
- if (contentPath.length == 0)
+ if (contentList.size() == 0)
{
- contentPath = new IContent[] { self };
+ contentList.add(new IContent[] { self });
}
- return contentPath;
+ return (IContent[]) contentList.toArray(new IContent[contentList.size()]);
}
finally
{
diff --git a/framework/src/main/java/org/apache/felix/moduleloader/JarContent.java b/framework/src/main/java/org/apache/felix/moduleloader/JarContent.java
index 0070ae8..0adfe55 100644
--- a/framework/src/main/java/org/apache/felix/moduleloader/JarContent.java
+++ b/framework/src/main/java/org/apache/felix/moduleloader/JarContent.java
@@ -19,9 +19,7 @@
package org.apache.felix.moduleloader;
import java.io.*;
-import java.util.*;
import java.util.Enumeration;
-import java.util.NoSuchElementException;
import java.util.zip.ZipEntry;
import org.apache.felix.framework.util.SecureAction;
@@ -274,7 +272,6 @@
private static class EntriesEnumeration implements Enumeration
{
private Enumeration m_enumeration = null;
- private Object m_next = null;
public EntriesEnumeration(Enumeration enumeration)
{