FELIX-591 Guard disableInternal and disposeInternal against disabling after
the component has already been disposed.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@662387 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/AbstractComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/AbstractComponentManager.java
index 00499c8..671b61b 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/AbstractComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/AbstractComponentManager.java
@@ -504,6 +504,14 @@
     {
         // CONCURRENCY NOTE: This method is only called from the BundleComponentActivator or by application logic
         // but not by the dependency managers
+        
+        // if the component is already disabled or destroyed, we have
+        // nothing to do
+        if ( ( getState() & ( STATE_DISABLED | STATE_DESTROYED ) ) != 0 )
+        {
+            log( LogService.LOG_DEBUG, "Component already disabled", m_componentMetadata, null );
+            return;
+        }
 
         // deactivate first, this does nothing if not active/registered/factory
         deactivateInternal();
@@ -535,6 +543,13 @@
         // CONCURRENCY NOTE: This method is only called from the BundleComponentActivator or by application logic
         // but not by the dependency managers
 
+        // if the component is already destroyed, we have nothing to do
+        if ( getState() == STATE_DESTROYED )
+        {
+            log( LogService.LOG_DEBUG, "Component already destroyed", m_componentMetadata, null );
+            return;
+        }
+
         // disable first to clean up correctly
         disableInternal();