[jboss-osgi-commits] JBoss-OSGI SVN: r93107 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Tue Sep 1 19:58:52 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-09-01 19:58:52 -0400 (Tue, 01 Sep 2009)
New Revision: 93107

Modified:
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
Log:
Prevent NPE on missing packageadmin service

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java	2009-09-01 23:58:19 UTC (rev 93106)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java	2009-09-01 23:58:52 UTC (rev 93107)
@@ -165,22 +165,25 @@
    public void refreshPackages(String[] symbolicNames)
    {
       ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());
-      PackageAdmin service = (PackageAdmin)systemContext.getService(sref);
+      if (sref != null)
+      {
+         PackageAdmin service = (PackageAdmin)systemContext.getService(sref);
 
-      Bundle[] bundles = null;
-      if (symbolicNames != null)
-      {
-         List<String> nameList = Arrays.asList(symbolicNames);
-         Set<Bundle> bundleSet = new HashSet<Bundle>();
-         for (Bundle bundle : systemContext.getBundles())
+         Bundle[] bundles = null;
+         if (symbolicNames != null)
          {
-            if (nameList.contains(bundle.getSymbolicName()))
-               bundleSet.add(bundle);
+            List<String> nameList = Arrays.asList(symbolicNames);
+            Set<Bundle> bundleSet = new HashSet<Bundle>();
+            for (Bundle bundle : systemContext.getBundles())
+            {
+               if (nameList.contains(bundle.getSymbolicName()))
+                  bundleSet.add(bundle);
+            }
+            bundles = new Bundle[bundleSet.size()];
+            bundleSet.toArray(bundles);
          }
-         bundles = new Bundle[bundleSet.size()];
-         bundleSet.toArray(bundles);
+         service.refreshPackages(bundles);
       }
-      service.refreshPackages(bundles);
    }
 
    public void start()



More information about the jboss-osgi-commits mailing list