Fixed logic error where a Resource was being removed from the list
of candidates when it should have been a Capability. (FELIX-1792)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@898931 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 814f402..412ac59 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResolverImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResolverImpl.java
@@ -193,16 +193,16 @@
                         // can resolve.
                         while ((candidate == null) && !candidateCapabilities.isEmpty())
                         {
-                            Resource bestResource = (Resource) getBestCandidate(candidateCapabilities);
+                            Capability bestCapability = getBestCandidate(candidateCapabilities);
 
                             // Try to resolve the best resource.
-                            if (resolve(bestResource))
+                            if (resolve(((CapabilityImpl) bestCapability).getResource()))
                             {
-                                candidate = bestResource;
+                                candidate = ((CapabilityImpl) bestCapability).getResource();
                             }
                             else
                             {
-                                candidateCapabilities.remove(bestResource);
+                                candidateCapabilities.remove(bestCapability);
                             }
                         }
                     }
@@ -380,7 +380,7 @@
      * @param resources
      * @return
      */
-    private Resource getBestCandidate(List caps)
+    private Capability getBestCandidate(List caps)
     {
         Version bestVersion = null;
         Capability best = null;
@@ -434,7 +434,7 @@
             }
         }
 
-        return (best == null) ? null : ((CapabilityImpl) best).getResource();
+        return (best == null) ? null : best;
     }
 
     public synchronized void deploy(boolean start)
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResourceImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResourceImpl.java
index bd2925f..4f52b9d 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResourceImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResourceImpl.java
@@ -67,12 +67,12 @@
 
     public boolean equals(Object o)
     {
-        if (getSymbolicName() == null || getVersion() == null)
-        {
-            return this == o;
-        }
         if (o instanceof Resource)
         {
+            if (getSymbolicName() == null || getVersion() == null)
+            {
+                return this == o;
+            }
             return getSymbolicName().equals(((Resource) o).getSymbolicName())
                 && getVersion().equals(((Resource) o).getVersion());
         }