FELIX-2231 Prevent NullPointerException if configuration is updated/deleted after the held components have already been disposed off
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@926989 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/config/ConfiguredComponentHolder.java b/scr/src/main/java/org/apache/felix/scr/impl/config/ConfiguredComponentHolder.java
index 5dcffc6..a4e0bf7 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/config/ConfiguredComponentHolder.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/config/ConfiguredComponentHolder.java
@@ -64,13 +64,16 @@
/**
* The special component used if there is no configuration or a singleton
- * configuration. This field is always non-<code>null</code> and is first
- * created in the constructor. As factory configurations are provided this
- * instance may be configured or "deconfigured".
+ * configuration. This field is only <code>null</code> once all components
+ * held by this holder have been disposed off by
+ * {@link #disposeComponents(int)} and is first created in the constructor.
+ * As factory configurations are provided this instance may be configured
+ * or "deconfigured".
* <p>
* Expected invariants:
* <ul>
- * <li>This field is never <code>null</code></li>
+ * <li>This field is only <code>null</code> after disposal of all held
+ * components</li>
* <li>The {@link #m_components} map is empty or the component pointed to
* by this field is also contained in the map</li>
* <ul>
@@ -119,6 +122,11 @@
*/
public void configurationDeleted( final String pid )
{
+ // FELIX-2231: nothing to do any more, all components have been disposed off
+ if (m_singleComponent == null) {
+ return;
+ }
+
if ( pid.equals( getComponentName() ) )
{
// singleton configuration deleted
@@ -181,6 +189,11 @@
*/
public void configurationUpdated( final String pid, final Dictionary props )
{
+ // FELIX-2231: nothing to do any more, all components have been disposed off
+ if (m_singleComponent == null) {
+ return;
+ }
+
if ( pid.equals( getComponentName() ) )
{
// singleton configuration has pid equal to component name