aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r1080545 - /aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java
Date Fri, 11 Mar 2011 12:21:43 GMT
Author: not
Date: Fri Mar 11 12:21:42 2011
New Revision: 1080545

URL: http://svn.apache.org/viewvc?rev=1080545&view=rev
Log:
ARIES-608 Cope with the current Bundle not having a BundleContext during static initialization.

Modified:
    aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java

Modified: aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java?rev=1080545&r1=1080544&r2=1080545&view=diff
==============================================================================
--- aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java (original)
+++ aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java Fri Mar
11 12:21:42 2011
@@ -36,8 +36,22 @@ import org.osgi.framework.FrameworkUtil;
 public class DefaultWorker implements FrameworkUtilWorker, BundleListener, FrameworkListener
 {
   private Map<Bundle, ClassLoader> classLoaders = new IdentityHashMap<Bundle, ClassLoader>();
-  private static final Bundle myFrameworkBundle = FrameworkUtil.getBundle(DefaultWorker.class).getBundleContext().getBundle(0);
+  private static final Bundle myFrameworkBundle;
 
+  static
+  {
+    BundleContext myContext = FrameworkUtil.getBundle(DefaultWorker.class).getBundleContext();
+    
+    // This may be created during framework shutdown when the bundle context is null.
+    // So we need to cope and not NPE during construction.
+    if (myContext != null) {
+      myFrameworkBundle = myContext.getBundle(0);
+    } else {
+      myFrameworkBundle = null;
+    }
+  }
+  
+  
   public ClassLoader getClassLoader(final Bundle b) 
   {
     ClassLoader cl = get(b);



Mime
View raw message