You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2015/02/09 17:35:27 UTC

svn commit: r1658457 - /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java

Author: fmeschbe
Date: Mon Feb  9 16:35:26 2015
New Revision: 1658457

URL: http://svn.apache.org/r1658457
Log:
FELIX-4792 Catch Throwable during initial initialization of components and log

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java?rev=1658457&r1=1658456&r2=1658457&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java Mon Feb  9 16:35:26 2015
@@ -163,7 +163,7 @@ public class BundleComponentActivator im
 
 
     /**
-     * Called outside the constructor so that the m_managers field is completely initialized.  
+     * Called outside the constructor so that the m_managers field is completely initialized.
      * A component might possibly start a thread to enable other components, which could access m_managers
      */
     void initialEnable()
@@ -179,7 +179,28 @@ public class BundleComponentActivator im
                 log( LogService.LOG_DEBUG, "BundleComponentActivator : Bundle [{0}] Enabling component holder {1}",
                         new Object[] {m_bundle.getBundleId(), componentHolder.getComponentMetadata().getName()}, null, null, null );
 
-                componentHolder.enableComponents( false );
+                try
+                {
+                    componentHolder.enableComponents( false );
+                }
+                catch ( Throwable t )
+                {
+                    // caught on unhandled RuntimeException or Error
+                    // (e.g. ClassDefNotFoundError)
+
+                    // make sure the component is properly disabled, just in case
+                    try
+                    {
+                        componentHolder.disableComponents( false );
+                    }
+                    catch ( Throwable ignore )
+                    {
+                    }
+
+                    log( LogService.LOG_ERROR,
+                        "BundleComponentActivator : Bundle [{0}] Unexpected failure enabling component holder {1}",
+                        new Object[] { m_bundle.getBundleId(), componentHolder.getComponentMetadata().getName() }, null, null, t );
+                }
             }
             else
             {
@@ -361,7 +382,7 @@ public class BundleComponentActivator im
             m_logService.close();
             m_closeLatch.countDown();
         }
-        else 
+        else
         {
             try
             {