felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r797157 - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: ExtensionManager.java Felix.java
Date Thu, 23 Jul 2009 17:32:11 GMT
Author: rickhall
Date: Thu Jul 23 17:32:11 2009
New Revision: 797157

URL: http://svn.apache.org/viewvc?rev=797157&view=rev
Log:
Remove some potential deadlocks. (FELIX-1287)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java?rev=797157&r1=797156&r2=797157&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java Thu
Jul 23 17:32:11 2009
@@ -106,7 +106,7 @@
         m_extensionManager = extensionManager;
     }
 
-    private Logger m_logger = null;
+    private final Logger m_logger;
     private final Map m_headerMap = new StringMap(false);
     private final IModule m_module;
     private ICapability[] m_capabilities = null;
@@ -120,6 +120,7 @@
     // classloader.
     private ExtensionManager()
     {
+        m_logger = null;
         m_module = null;
         m_extensions = new ArrayList();
         m_names = new HashSet();
@@ -188,7 +189,7 @@
         }
     }
 
-    private ICapability[] aliasSymbolicName(ICapability[] caps)
+    private static ICapability[] aliasSymbolicName(ICapability[] caps)
     {
         if (caps == null)
         {
@@ -258,7 +259,7 @@
      *          AdminPermission.EXTENSIONLIFECYCLE and security is enabled.
      * @throws Exception in case something goes wrong.
      */
-    void addExtensionBundle(Felix felix, BundleImpl bundle)
+    synchronized void addExtensionBundle(Felix felix, BundleImpl bundle)
         throws SecurityException, BundleException, Exception
     {
         Object sm = System.getSecurityManager();
@@ -284,9 +285,6 @@
                 "Unsupported Extension Bundle type!"));
         }
 
-        // Not sure whether this is a good place to do it but we need to lock
-        felix.acquireBundleLock(felix, Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE);
-
         try
         {
 // TODO: EXTENSIONMANAGER - Should we be setting this?
@@ -335,10 +333,6 @@
 //            bundle.setExtension(false);
             throw ex;
         }
-        finally
-        {
-            felix.releaseBundleLock(felix);
-        }
 
         felix.setBundleStateAndNotify(bundle, Bundle.RESOLVED);
     }
@@ -400,7 +394,7 @@
         }
     }
 
-    void setCapabilities(ICapability[] capabilities)
+    private void setCapabilities(ICapability[] capabilities)
     {
         m_capabilities = capabilities;
         m_headerMap.put(Constants.EXPORT_PACKAGE, convertCapabilitiesToHeaders(m_headerMap));
@@ -627,12 +621,18 @@
 
         public Map getHeaders()
         {
-            return m_headerMap;
+            synchronized (ExtensionManager.this)
+            {
+                return m_headerMap;
+            }
         }
 
         public ICapability[] getCapabilities()
         {
-            return m_capabilities;
+            synchronized (ExtensionManager.this)
+            {
+                return m_capabilities;
+            }
         }
 
         public String getSymbolicName()
@@ -647,9 +647,12 @@
 
         public Class getClassByDelegation(String name) throws ClassNotFoundException
         {
-            if (!m_exportNames.contains(Util.getClassPackage(name)))
+            synchronized (ExtensionManager.this)
             {
-                throw new ClassNotFoundException(name);
+                if (!m_exportNames.contains(Util.getClassPackage(name)))
+                {
+                    throw new ClassNotFoundException(name);
+                }
             }
 
             return getClass().getClassLoader().loadClass(name);
@@ -719,4 +722,4 @@
             return getClass().getClassLoader().getResourceAsStream(urlPath);
         }
     }
-}
+}
\ No newline at end of file

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=797157&r1=797156&r2=797157&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java Thu Jul 23 17:32:11
2009
@@ -1898,25 +1898,7 @@
                 }
                 else
                 {
-                    // Acquire bundle lock.
-                    try
-                    {
-                        acquireBundleLock(this, Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE);
-                    }
-                    catch (IllegalStateException ex)
-                    {
-                        throw new BundleException(
-                            "System bundle must be active to attach an extension.");
-                    }
-
-                    try
-                    {
-                        m_extensionManager.startExtensionBundle(this, bundle);
-                    }
-                    finally
-                    {
-                        releaseBundleLock(this);
-                    }
+                    m_extensionManager.startExtensionBundle(this, bundle);
                 }
 
                 fireBundleEvent(BundleEvent.UNRESOLVED, bundle);
@@ -2482,25 +2464,7 @@
 
             if (bundle.isExtension())
             {
-                // Acquire bundle lock.
-                try
-                {
-                    acquireBundleLock(this, Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE);
-                }
-                catch (IllegalStateException ex)
-                {
-                    throw new BundleException(
-                        "System bundle must be active to attach an extension.");
-                }
-
-                try
-                {
-                    m_extensionManager.startExtensionBundle(this, bundle);
-                }
-                finally
-                {
-                    releaseBundleLock(this);
-                }
+                m_extensionManager.startExtensionBundle(this, bundle);
             }
         }
         finally



Mime
View raw message