FELIX-2126: Dependencies of optional resources should be optional

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@915363 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResolverImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResolverImpl.java
index a8375fb..aa19596 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResolverImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResolverImpl.java
@@ -176,7 +176,7 @@
             {
                 fake.addRequire((Requirement) iter.next());
             }
-            if (!resolve(fake, locals, remotes))
+            if (!resolve(fake, locals, remotes, false))
             {
                 result = false;
             }
@@ -185,7 +185,7 @@
         // Loop through each resource in added list and resolve.
         for (Iterator iter = m_addedSet.iterator(); iter.hasNext(); )
         {
-            if (!resolve((Resource) iter.next(), locals, remotes))
+            if (!resolve((Resource) iter.next(), locals, remotes, false))
             {
                 // If any resource does not resolve, then the
                 // entire result will be false.
@@ -204,7 +204,7 @@
         return result;
     }
 
-    private boolean resolve(Resource resource, Resource[] locals, Resource[] remotes)
+    private boolean resolve(Resource resource, Resource[] locals, Resource[] remotes, boolean optional)
     {
         boolean result = true;
 
@@ -246,7 +246,7 @@
                             Capability bestCapability = getBestCandidate(candidateCapabilities);
 
                             // Try to resolve the best resource.
-                            if (resolve(((CapabilityImpl) bestCapability).getResource(), locals, remotes))
+                            if (resolve(((CapabilityImpl) bestCapability).getResource(), locals, remotes, optional || reqs[reqIdx].isOptional()))
                             {
                                 candidate = ((CapabilityImpl) bestCapability).getResource();
                             }
@@ -282,11 +282,11 @@
                 {
 
                     // Try to resolve the candidate.
-                    if (resolve(candidate, locals, remotes))
+                    if (resolve(candidate, locals, remotes, optional || reqs[reqIdx].isOptional()))
                     {
                         // The resolved succeeded; record the candidate
                         // as either optional or required.
-                        if (reqs[reqIdx].isOptional())
+                        if (optional || reqs[reqIdx].isOptional())
                         {
                             m_optionalSet.add(candidate);
                         }