Fixed an improper loop index in RequiredBundle.getRequiringBundles() and
also made the method a little more efficient. (FELIX-1920)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@887289 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java b/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java
index 60694cf..897022e 100644
--- a/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java
@@ -63,8 +63,9 @@
         }
 
         // We need to find all modules that require any of the modules
-        // associated with this bundle.
-        List moduleList = new ArrayList();
+        // associated with this bundle and save the associated bundle
+        // of the dependent modules.
+        Set bundleSet = new HashSet();
         // Loop through all of this bundle's modules.
         IModule[] modules = m_bundle.getModules();
         for (int modIdx = 0; (modules != null) && (modIdx < modules.length); modIdx++)
@@ -74,20 +75,13 @@
             IModule[] dependents = ((ModuleImpl) modules[modIdx]).getDependentRequirers();
             for (int depIdx = 0; (dependents != null) && (depIdx < dependents.length); depIdx++)
             {
-                moduleList.add(dependents[modIdx]);
+                if (dependents[depIdx].getBundle() != null)
+                {
+                    bundleSet.add(dependents[depIdx].getBundle());
+                }
             }
         }
-        // Convert the list of dependent modules into a non-duplicated
-        // array of bundles.
-        Set bundleSet = new HashSet();
-        for (int modIdx = 0; modIdx < moduleList.size(); modIdx++)
-        {
-            Bundle bundle = ((IModule) moduleList.get(modIdx)).getBundle();
-            if (bundle != null)
-            {
-                bundleSet.add(bundle);
-            }
-        }
+        // Convert to an array.
         return (Bundle[]) bundleSet.toArray(new Bundle[bundleSet.size()]);
     }