You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Richard S. Hall (JIRA)" <ji...@apache.org> on 2013/02/05 19:14:12 UTC

[jira] [Resolved] (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 ]

Richard S. Hall resolved FELIX-3766.
------------------------------------

    Resolution: Fixed
      Assignee: Richard S. Hall  (was: Guillaume Nodet)

Since I couldn't think of any reasons why not, I went ahead and basically applied the supplied patch. This pre-check is still just an approximation, since it doesn't take into account resolver hooks, but it should make it more accurate. Please close if satisfied, thanks.
                
> 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: Richard S. Hall
>             Fix For: framework-4.2.0
>
>
> 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