Author: gnodet
Date: Fri Dec 14 16:23:01 2012
New Revision: 1421961

URL: http://svn.apache.org/viewvc?rev=1421961&view=rev
Log:
[FELIX-3803] Bundle#getResource and Bundle#findEntries always try to resolve 
the bundle (hence grabbing the bundle lock) even if the bundle is already 
resolved, which contradicts the spec

Modified:
    
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java

Modified: 
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=1421961&r1=1421960&r2=1421961&view=diff
==============================================================================
--- 
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java 
(original)
+++ 
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java 
Fri Dec 14 16:23:01 2012
@@ -304,7 +304,7 @@ class BundleImpl implements Bundle, Bund
         }
 
         return getFramework().findBundleEntries(
-            adapt(BundleRevisionImpl.class), path, filePattern, recurse);
+                this, path, filePattern, recurse);
     }
 
     public Dictionary getHeaders()
@@ -1291,4 +1291,4 @@ class BundleImpl implements Bundle, Bund
     {
         return m_context;
     }
-}
\ No newline at end of file
+}

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=1421961&r1=1421960&r2=1421961&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 
Fri Dec 14 16:23:01 2012
@@ -1567,13 +1567,16 @@ public class Felix extends BundleImpl im
         {
             return null;
         }
-        try
-        {
-            resolveBundleRevision(bundle.adapt(BundleRevision.class));
-        }
-        catch (Exception ex)
+        else if (bundle.getState() == Bundle.INSTALLED)
         {
-            // Ignore.
+            try
+            {
+                resolveBundleRevision(bundle.adapt(BundleRevision.class));
+            }
+            catch (Exception ex)
+            {
+                // Ignore.
+            }
         }
 
         // If the bundle revision isn't resolved, then just search
@@ -1603,13 +1606,16 @@ public class Felix extends BundleImpl im
         {
             return null;
         }
-        try
-        {
-            resolveBundleRevision(bundle.adapt(BundleRevision.class));
-        }
-        catch (Exception ex)
+        else if (bundle.getState() == Bundle.INSTALLED)
         {
-            // Ignore.
+            try
+            {
+                resolveBundleRevision(bundle.adapt(BundleRevision.class));
+            }
+            catch (Exception ex)
+            {
+                // Ignore.
+            }
         }
 
         if (bundle.adapt(BundleRevision.class).getWiring() == null)
@@ -1688,13 +1694,33 @@ public class Felix extends BundleImpl im
      * Implementation for Bundle.findEntries().
     **/
     Enumeration findBundleEntries(
-        BundleRevision revision, String path, String filePattern, boolean 
recurse)
+            BundleImpl bundle, String path, String filePattern, boolean 
recurse)
     {
-        // Try to resolve the bundle per the spec.
-        List<Bundle> list = new ArrayList<Bundle>(1);
-        list.add(revision.getBundle());
-        resolveBundles(list);
+        if (bundle.getState() == Bundle.UNINSTALLED)
+        {
+            throw new IllegalStateException("The bundle is uninstalled.");
+        }
+        else if (!Util.isFragment(bundle.adapt(BundleRevision.class)) && 
bundle.getState() == Bundle.INSTALLED)
+        {
+            try
+            {
+                resolveBundleRevision(bundle.adapt(BundleRevision.class));
+            }
+            catch (Exception ex)
+            {
+                // Ignore.
+            }
+        }
+        return findBundleEntries(
+                bundle.adapt(BundleRevision.class), path, filePattern, 
recurse);
+    }
 
+    /**
+     * Implementation for BundleWiring.findEntries().
+     **/
+    Enumeration findBundleEntries(
+        BundleRevision revision, String path, String filePattern, boolean 
recurse)
+    {
         // Get the entry enumeration from the revision content and
         // create a wrapper enumeration to filter it.
         Enumeration enumeration =


Reply via email to