FELIX-4171 don't try to close DependencyManagers we didn't open

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1504336 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
index 0f9c91d..ff31830 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
@@ -270,10 +270,17 @@
                         new Object[]
                                 {dm.getName()}, null );
 
-                // make sure, we keep no bindings
+                // make sure, we keep no bindings. Only close the dm's we opened.
+                boolean skip = true;
                 for ( DependencyManager md: getReversedDependencyManagers() )
                 {
-                    md.close( implementationObject, componentContext.getEdgeInfo( md ) );
+                    if ( skip && dm == md ) {
+                        skip = false;
+                    }
+                    if ( !skip )
+                    {
+                        md.close( implementationObject, componentContext.getEdgeInfo( md ) );
+                    }
                 }
 
                 setter.resetImplementationObject( implementationObject );