FELIX-4138 TypeDeclaration calls factory.dispose() even if it already has been disposed (externally)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1498508 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
index c817093..3f5ee5c 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
@@ -609,6 +609,12 @@
* The factory cannot be restarted. Only the {@link Extender} can call this method.
*/
public synchronized void dispose() {
+ // Fast exit if already disposed
+ // The m_listeners field is ONLY set to null after dispose(), so if it's null, that
+ // means the factory has already be disposed. We can return safely.
+ if (m_listeners == null) {
+ return;
+ }
stop(); // Does not hold the lock.
m_requiredHandlers.clear();
m_listeners = null;