[ https://issues.apache.org/jira/browse/FELIX-3807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13531179#comment-13531179 ]
Guillaume Nodet commented on FELIX-3807: ---------------------------------------- Here is a proposed patch: {code} 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 5caf1d3..9346e11 100644 --- a/framework/src/main/java/org/apache/felix/framework/Felix.java +++ b/framework/src/main/java/org/apache/felix/framework/Felix.java @@ -4221,6 +4221,15 @@ public class Felix extends BundleImpl implements Framework helpers.add(new RefreshHelper(b)); } + // Lock all refreshing bundles. + for (RefreshHelper helper : helpers) + { + if (helper != null) + { + helper.lock(); + } + } + // Stop all refreshing bundles. for (RefreshHelper helper : helpers) { @@ -4247,6 +4256,15 @@ public class Felix extends BundleImpl implements Framework helper.restart(); } } + + // Unlock all refreshing bundles. + for (RefreshHelper helper : helpers) + { + if (helper != null) + { + helper.unlock(); + } + } } else { @@ -4970,15 +4988,37 @@ public class Felix extends BundleImpl implements Framework { private BundleImpl m_bundle = null; private int m_oldState = Bundle.INSTALLED; + private boolean m_locked; public RefreshHelper(Bundle bundle) { m_bundle = (BundleImpl) bundle; } + public void lock() + { + try + { + acquireBundleLock(m_bundle, + Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING); + m_locked = true; + } + catch (Throwable ex) + { + fireFrameworkEvent(FrameworkEvent.ERROR, m_bundle, ex); + } + } + + public void unlock() + { + if (m_locked) + { + releaseBundleLock(m_bundle); + } + } + public void stop() { -// TODO: LOCKING - This is not really correct. if (m_bundle.getState() == Bundle.ACTIVE) { m_oldState = Bundle.ACTIVE; {code} > Refreshing bundles should first grab all the bundle locks to avoid concurrent > modifications of those bundles > ------------------------------------------------------------------------------------------------------------ > > Key: FELIX-3807 > URL: https://issues.apache.org/jira/browse/FELIX-3807 > Project: Felix > Issue Type: Improvement > Components: Framework > Reporter: Guillaume Nodet > > This will avoid possible problems where bundles states can change between > stopping the bundle and actually refreshing them. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira