FELIX-5015 NPE in ResolverImpl

Applying patch on behalf of Alexandre Roman with many thanks!


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1705679 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java b/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
index 1484064..cf7daa0 100644
--- a/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
+++ b/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
@@ -1717,7 +1717,25 @@
     private static Set<Capability> getPackageSources(
             Capability cap, Map<Resource, Packages> resourcePkgMap)
     {
-        return resourcePkgMap.get(cap.getResource()).m_sources.get(cap);
+        Resource resource = cap.getResource();
+        if(resource == null)
+        {
+            return new HashSet<Capability>();
+        }
+
+        OpenHashMap<Capability, Set<Capability>> sources = resourcePkgMap.get(resource).m_sources;
+        if(sources == null)
+        {
+            return new HashSet<Capability>();
+        }
+
+        Set<Capability> packageSources = sources.get(cap);
+        if(packageSources == null) 
+        {
+            return new HashSet<Capability>();
+        }
+
+        return packageSources;  
     }
 
     private static void getPackageSourcesInternal(