[FELIX-3807] Make sure bundle locks are always acquired during refresh to ensure bundles are stopped
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1421962 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index 78bbeed..ffff6e8 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -4706,18 +4706,21 @@
public void stop()
{
-// TODO: LOCKING - This is not really correct.
- if (m_bundle.getState() == Bundle.ACTIVE)
+ acquireBundleLock(m_bundle,
+ Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING |
+ Bundle.ACTIVE | Bundle.STOPPING);
+ try
{
- m_oldState = Bundle.ACTIVE;
- try
- {
- stopBundle(m_bundle, false);
- }
- catch (Throwable ex)
- {
- fireFrameworkEvent(FrameworkEvent.ERROR, m_bundle, ex);
- }
+ m_oldState = m_bundle.getState();
+ stopBundle(m_bundle, false);
+ }
+ catch (Throwable ex)
+ {
+ fireFrameworkEvent(FrameworkEvent.ERROR, m_bundle, ex);
+ }
+ finally
+ {
+ releaseBundleLock(m_bundle);
}
}