Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-3766

Slightly invalid logic for pre-checking dynamic imports which cause the framework the grab the lock with no real need

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • framework-4.0.2
    • framework-4.2.0
    • Framework
    • None

    Description

      Proposed patch

      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();
      

      Attachments

        Activity

          People

            rickhall Richard S. Hall
            gnodet Guillaume Nodet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: