Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-06-02 21:19:23 +0000
committerThomas Watson2016-06-03 13:36:12 +0000
commit9a6165fbb48f1c583c967e6debb1d23250b4fd29 (patch)
treeba760cc2558fda92b017d0137a6b1c173185d230 /bundles/org.eclipse.osgi/container
parentf355e41034d9d0a2969dc9331f910da7a7e8d565 (diff)
downloadrt.equinox.framework-9a6165fbb48f1c583c967e6debb1d23250b4fd29.tar.gz
rt.equinox.framework-9a6165fbb48f1c583c967e6debb1d23250b4fd29.tar.xz
rt.equinox.framework-9a6165fbb48f1c583c967e6debb1d23250b4fd29.zip
Bug 495333 - ContextFinder returns null from getResourcesR4_6I20160606-1100I20160603-1000
If there are no classes loaded from bundle class loaders on the stack then ContextFinder.getResources can return null. This fix ensures an empty enumeration is returned instead. Change-Id: I07fe25eeaf8d02ea92cbe130794cdd2a011ae481 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi/container')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
index 5fcfed8d1..2e7f0e319 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
@@ -64,6 +64,10 @@ public class BundleLoader extends ModuleLoader {
private static final Pattern PACKAGENAME_FILTER = Pattern.compile("\\(osgi.wiring.package\\s*=\\s*([^)]+)\\)"); //$NON-NLS-1$
+ // TODO needed instead of using Collections.emptyEnumertion until we no longer support Java 6
+ @SuppressWarnings("rawtypes")
+ private final static Enumeration EMPTY_ENUMERATION = Collections.enumeration(Collections.emptyList());
+
private final ModuleWiring wiring;
private final EquinoxContainer container;
private final Debug debug;
@@ -627,7 +631,7 @@ public class BundleLoader extends ModuleLoader {
if ((name.length() > 1) && (name.charAt(0) == '/')) /* if name has a leading slash */
name = name.substring(1); /* remove leading slash before search */
String pkgName = getResourcePackageName(name);
- Enumeration<URL> result = Collections.enumeration(Collections.<URL> emptyList());
+ Enumeration<URL> result = emptyEnumeration();
boolean bootDelegation = false;
// follow the OSGi delegation model
// First check the parent classloader for system resources, if it is a java resource.
@@ -781,9 +785,9 @@ public class BundleLoader extends ModuleLoader {
public static <E> Enumeration<E> compoundEnumerations(Enumeration<E> list1, Enumeration<E> list2) {
if (list2 == null || !list2.hasMoreElements())
- return list1;
+ return list1 == null ? BundleLoader.<E> emptyEnumeration() : list1;
if (list1 == null || !list1.hasMoreElements())
- return list2;
+ return list2 == null ? BundleLoader.<E> emptyEnumeration() : list2;
List<E> compoundResults = new ArrayList<E>();
while (list1.hasMoreElements())
compoundResults.add(list1.nextElement());
@@ -795,6 +799,11 @@ public class BundleLoader extends ModuleLoader {
return Collections.enumeration(compoundResults);
}
+ @SuppressWarnings("unchecked")
+ private static <E> Enumeration<E> emptyEnumeration() {
+ return EMPTY_ENUMERATION;
+ }
+
/**
* Finds a resource local to this bundle. Only the classloader for this bundle is searched.
* @param name The name of the resource to find.

Back to the top