You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Guillaume Nodet (JIRA)" <ji...@apache.org> on 2012/11/19 01:42:58 UTC
[jira] [Updated] (FELIX-3766) Slightly invalid logic for
pre-checking dynamic imports which cause the framework the grab the lock
with no real need
[ https://issues.apache.org/jira/browse/FELIX-3766?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Guillaume Nodet updated FELIX-3766:
-----------------------------------
Description:
Proposed patch
{code}
diff --git a/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java b/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
index cc9a387..7255649 100644
--- a/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
+++ b/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
@@ -39,6 +39,7 @@ import org.apache.felix.framework.resolver.ResolverWire;
import org.apache.felix.framework.util.ShrinkableCollection;
import org.apache.felix.framework.util.Util;
import org.apache.felix.framework.util.manifestparser.R4Library;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
import org.apache.felix.framework.wiring.BundleRequirementImpl;
import org.apache.felix.framework.wiring.BundleWireImpl;
import org.osgi.framework.Bundle;
@@ -755,6 +756,44 @@ class StatefulResolver
attrs);
List<BundleCapability> candidates = findProviders(req, false);
+ // Try to find a dynamic requirement that matches the capabilities.
+ BundleRequirementImpl dynReq = null;
+ for (int dynIdx = 0;
+ (candidates.size() > 0) && (dynReq == null) && (dynIdx < dynamics.size());
+ dynIdx++)
+ {
+ for (Iterator<BundleCapability> itCand = candidates.iterator();
+ (dynReq == null) && itCand.hasNext(); )
+ {
+ BundleCapability cap = itCand.next();
+ if (CapabilitySet.matches(
+ (BundleCapabilityImpl) cap,
+ ((BundleRequirementImpl) dynamics.get(dynIdx)).getFilter()))
+ {
+ dynReq = (BundleRequirementImpl) dynamics.get(dynIdx);
+ }
+ }
+ }
+
+ // If we found a matching dynamic requirement, then filter out
+ // any candidates that do not match it.
+ if (dynReq != null)
+ {
+ for (Iterator<BundleCapability> itCand = candidates.iterator();
+ itCand.hasNext(); )
+ {
+ BundleCapability cap = itCand.next();
+ if (!CapabilitySet.matches(cap, dynReq.getFilter()))
+ {
+ itCand.remove();
+ }
+ }
+ }
+ else
+ {
+ candidates.clear();
+ }
+
return !candidates.isEmpty();
{code}
was:
{code}
diff --git a/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java b/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
index cc9a387..7255649 100644
--- a/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
+++ b/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
@@ -39,6 +39,7 @@ import org.apache.felix.framework.resolver.ResolverWire;
import org.apache.felix.framework.util.ShrinkableCollection;
import org.apache.felix.framework.util.Util;
import org.apache.felix.framework.util.manifestparser.R4Library;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
import org.apache.felix.framework.wiring.BundleRequirementImpl;
import org.apache.felix.framework.wiring.BundleWireImpl;
import org.osgi.framework.Bundle;
@@ -755,6 +756,44 @@ class StatefulResolver
attrs);
List<BundleCapability> candidates = findProviders(req, false);
+ // Try to find a dynamic requirement that matches the capabilities.
+ BundleRequirementImpl dynReq = null;
+ for (int dynIdx = 0;
+ (candidates.size() > 0) && (dynReq == null) && (dynIdx < dynamics.size());
+ dynIdx++)
+ {
+ for (Iterator<BundleCapability> itCand = candidates.iterator();
+ (dynReq == null) && itCand.hasNext(); )
+ {
+ BundleCapability cap = itCand.next();
+ if (CapabilitySet.matches(
+ (BundleCapabilityImpl) cap,
+ ((BundleRequirementImpl) dynamics.get(dynIdx)).getFilter()))
+ {
+ dynReq = (BundleRequirementImpl) dynamics.get(dynIdx);
+ }
+ }
+ }
+
+ // If we found a matching dynamic requirement, then filter out
+ // any candidates that do not match it.
+ if (dynReq != null)
+ {
+ for (Iterator<BundleCapability> itCand = candidates.iterator();
+ itCand.hasNext(); )
+ {
+ BundleCapability cap = itCand.next();
+ if (!CapabilitySet.matches(cap, dynReq.getFilter()))
+ {
+ itCand.remove();
+ }
+ }
+ }
+ else
+ {
+ candidates.clear();
+ }
+
return !candidates.isEmpty();
{code}
> Slightly invalid logic for pre-checking dynamic imports which cause the framework the grab the lock with no real need
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: FELIX-3766
> URL: https://issues.apache.org/jira/browse/FELIX-3766
> Project: Felix
> Issue Type: Bug
> Components: Framework
> Affects Versions: framework-4.0.2
> Reporter: Guillaume Nodet
> Assignee: Guillaume Nodet
>
> Proposed patch
> {code}
> diff --git a/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java b/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
> index cc9a387..7255649 100644
> --- a/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
> +++ b/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
> @@ -39,6 +39,7 @@ import org.apache.felix.framework.resolver.ResolverWire;
> import org.apache.felix.framework.util.ShrinkableCollection;
> import org.apache.felix.framework.util.Util;
> import org.apache.felix.framework.util.manifestparser.R4Library;
> +import org.apache.felix.framework.wiring.BundleCapabilityImpl;
> import org.apache.felix.framework.wiring.BundleRequirementImpl;
> import org.apache.felix.framework.wiring.BundleWireImpl;
> import org.osgi.framework.Bundle;
> @@ -755,6 +756,44 @@ class StatefulResolver
> attrs);
> List<BundleCapability> candidates = findProviders(req, false);
>
> + // Try to find a dynamic requirement that matches the capabilities.
> + BundleRequirementImpl dynReq = null;
> + for (int dynIdx = 0;
> + (candidates.size() > 0) && (dynReq == null) && (dynIdx < dynamics.size());
> + dynIdx++)
> + {
> + for (Iterator<BundleCapability> itCand = candidates.iterator();
> + (dynReq == null) && itCand.hasNext(); )
> + {
> + BundleCapability cap = itCand.next();
> + if (CapabilitySet.matches(
> + (BundleCapabilityImpl) cap,
> + ((BundleRequirementImpl) dynamics.get(dynIdx)).getFilter()))
> + {
> + dynReq = (BundleRequirementImpl) dynamics.get(dynIdx);
> + }
> + }
> + }
> +
> + // If we found a matching dynamic requirement, then filter out
> + // any candidates that do not match it.
> + if (dynReq != null)
> + {
> + for (Iterator<BundleCapability> itCand = candidates.iterator();
> + itCand.hasNext(); )
> + {
> + BundleCapability cap = itCand.next();
> + if (!CapabilitySet.matches(cap, dynReq.getFilter()))
> + {
> + itCand.remove();
> + }
> + }
> + }
> + else
> + {
> + candidates.clear();
> + }
> +
> return !candidates.isEmpty();
> {code}
--
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