[FELIX-2849] PackageAdmin is inconsistent between getFragments and getHosts

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1072899 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java b/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
index b0fcd16..3317a45 100644
--- a/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
@@ -193,18 +193,21 @@
         // If the bundle is not a fragment, then return its fragments.
         if ((getBundleType(bundle) & BUNDLE_TYPE_FRAGMENT) == 0)
         {
-            // Get attached fragments.
-            List<Module> modules =
-                ((ModuleImpl)
-                    ((BundleImpl) bundle).getCurrentModule()).getFragments();
             // Convert fragment modules to bundles.
             List list = new ArrayList();
-            for (int i = 0; (modules != null) && (i < modules.size()); i++)
+            // Iterate through modules
+            List<Module> modules = ((BundleImpl) bundle).getModules();
+            for (int modIdx = 0; modIdx < modules.size(); modIdx++)
             {
-                Bundle b = modules.get(i).getBundle();
-                if (b != null)
+                // Get attached fragments.
+                List<Module> frags = ((ModuleImpl) modules.get(modIdx)).getFragments();
+                for (int i = 0; (frags != null) && (i < frags.size()); i++)
                 {
-                    list.add(b);
+                    Bundle b = frags.get(i).getBundle();
+                    if (b != null)
+                    {
+                        list.add(b);
+                    }
                 }
             }
             // Convert list to an array.