Author: rickhall
Date: Sun Sep 30 09:52:34 2007
New Revision: 580747
URL: http://svn.apache.org/viewvc?rev=580747&view=rev
Log:
Resolved a concurrency issue that could result in the same bundle being
resolved more than once; also tried to simplify locking in the core search
policy implementation. (FELIX-381)
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL:
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=580747&r1=580746&r2=580747&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Sun Sep 30 09:52:34 2007
@@ -623,8 +623,17 @@
acquireBundleLock(bundle);
if (bundle.getInfo().getCurrentModule() ==
event.getModule())
{
- bundle.getInfo().setState(Bundle.RESOLVED);
- fireBundleEvent(BundleEvent.RESOLVED, bundle);
+ if (bundle.getInfo().getState() !=
Bundle.INSTALLED)
+ {
+ m_logger.log(
+ Logger.LOG_WARNING,
+ "Received a resolve event for a bundle
that has already been resolved.");
+ }
+ else
+ {
+ bundle.getInfo().setState(Bundle.RESOLVED);
+ fireBundleEvent(BundleEvent.RESOLVED,
bundle);
+ }
}
}
finally
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
URL:
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java?rev=580747&r1=580746&r2=580747&view=diff
==============================================================================
---
felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
(original)
+++
felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
Sun Sep 30 09:52:34 2007
@@ -125,13 +125,23 @@
}
}
- protected synchronized boolean isResolved(IModule module)
+ /**
+ * Private utility method to check module resolved state.
+ * CONCURRENCY NOTE: This method must be called while holding
+ * a lock on m_factory.
+ **/
+ private boolean isResolved(IModule module)
{
ModuleData data = (ModuleData) m_moduleDataMap.get(module);
return (data == null) ? false : data.m_resolved;
}
- protected synchronized void setResolved(IModule module, boolean resolved)
+ /**
+ * Private utility method to set module resolved state.
+ * CONCURRENCY NOTE: This method must be called while holding
+ * a lock on m_factory.
+ **/
+ private void setResolved(IModule module, boolean resolved)
{
ModuleData data = (ModuleData) m_moduleDataMap.get(module);
if (data == null)
@@ -904,19 +914,6 @@
public void resolve(IModule rootModule)
throws ResolveException
{
- // If the module is already resolved, then we can just return.
- if (isResolved(rootModule))
- {
- return;
- }
-
- // This variable maps an unresolved module to a list of candidate
- // sets, where there is one candidate set for each requirement that
- // must be resolved. A candidate set contains the potential canidates
- // available to resolve the requirement and the currently selected
- // candidate index.
- Map candidatesMap = new HashMap();
-
// This map will be used to hold the final wires for all
// resolved modules, which can then be used to fire resolved
// events outside of the synchronized block.
@@ -927,6 +924,19 @@
// middle of this operation.
synchronized (m_factory)
{
+ // If the module is already resolved, then we can just return.
+ if (isResolved(rootModule))
+ {
+ return;
+ }
+
+ // This variable maps an unresolved module to a list of candidate
+ // sets, where there is one candidate set for each requirement that
+ // must be resolved. A candidate set contains the potential
canidates
+ // available to resolve the requirement and the currently selected
+ // candidate index.
+ Map candidatesMap = new HashMap();
+
// The first step is to populate the candidates map. This
// will use the target module to populate the candidates map
// with all potential modules that need to be resolved as a