When processing deferred activations, keep local copy of deferred list and
clear thread local so that any lazy activations triggered during activation
are handled separately. (FELIX-3306)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1232159 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
index af7cea8..ce063cb 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
@@ -2164,19 +2164,23 @@
&& (deferredList.size() > 0)
&& ((Object[]) deferredList.get(0))[0].equals(name))
{
- for (int i = deferredList.size() - 1; i >= 0; i--)
+ // Null the deferred list.
+ m_deferredActivation.set(null);
+ while (!deferredList.isEmpty())
{
+ // Lazy bundles should be activated in the reverse order
+ // of when they were added to the deferred list, so grab
+ // them from the end of the deferred list.
+ Object[] lazy = (Object[]) deferredList.remove(deferredList.size() - 1);
try
{
- felix.getFramework().activateBundle(
- (BundleImpl) ((Object[]) deferredList.get(i))[1], true);
+ felix.getFramework().activateBundle((BundleImpl) (lazy)[1], true);
}
catch (BundleException ex)
{
ex.printStackTrace();
}
}
- deferredList.clear();
}
}
}