FELIX-3787 Test dependencies map against null to prevent NPE on service update of inactive delayed components

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1414168 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
index 15d2def..2de96c8 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
@@ -380,14 +380,18 @@
                 }
                 else
                 {
-                    Map bound = ( Map ) m_componentManager.getDependencyMap().get( this );
-                    if ( m_dependencyMetadata.isMultiple() ||
-                                            bound.isEmpty() ||
-                                            reference.compareTo( bound.keySet().iterator().next() ) > 0 )
-                                    {
-                                        m_componentManager.deactivateInternal( ComponentConstants.DEACTIVATION_REASON_REFERENCE, false );
-                                        m_componentManager.activateInternal();
-                                    }
+                    Map dependenciesMap = m_componentManager.getDependencyMap();
+                    if ( dependenciesMap != null )
+                    {
+                        Map bound = ( Map ) dependenciesMap.get( this );
+                        if ( m_dependencyMetadata.isMultiple() ||
+                                                bound.isEmpty() ||
+                                                reference.compareTo( bound.keySet().iterator().next() ) > 0 )
+                                        {
+                                            m_componentManager.deactivateInternal( ComponentConstants.DEACTIVATION_REASON_REFERENCE, false );
+                                            m_componentManager.activateInternal();
+                                        }
+                    }
                 }
             }
 
@@ -404,12 +408,16 @@
                 else if ( !isReluctant() )
                 {
                     //dynamic greedy single: bind then unbind
-                    Map bound = ( Map ) m_componentManager.getDependencyMap().get( this );
-                    ServiceReference oldRef = ( ServiceReference ) bound.keySet().iterator().next();
-                    if ( reference.compareTo( oldRef ) > 0 )
+                    Map dependenciesMap = m_componentManager.getDependencyMap();
+                    if ( dependenciesMap != null )
                     {
-                        m_componentManager.invokeBindMethod( this, reference );
-                        m_componentManager.invokeUnbindMethod( this, oldRef );
+                        Map bound = ( Map ) dependenciesMap.get( this );
+                        ServiceReference oldRef = ( ServiceReference ) bound.keySet().iterator().next();
+                        if ( reference.compareTo( oldRef ) > 0 )
+                        {
+                            m_componentManager.invokeBindMethod( this, reference );
+                            m_componentManager.invokeUnbindMethod( this, oldRef );
+                        }
                     }
                 }
             }