felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r960035 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
Date Fri, 02 Jul 2010 15:45:14 GMT
Author: rickhall
Date: Fri Jul  2 15:45:14 2010
New Revision: 960035

URL: http://svn.apache.org/viewvc?rev=960035&view=rev
Log:
When resolving a module, try to rethrow a deep exception when an error
occurs. (FELIX-2459)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java?rev=960035&r1=960034&r2=960035&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
Fri Jul  2 15:45:14 2010
@@ -404,6 +404,7 @@ public class ResolverImpl implements Res
             Requirement req = remainingReqs.remove(0);
 
             // Get satisfying candidates and populate their candidates if necessary.
+            ResolveException rethrow = null;
             Set<Capability> candidates = state.getCandidates(module, req, true);
             for (Iterator<Capability> itCandCap = candidates.iterator(); itCandCap.hasNext();
)
             {
@@ -417,6 +418,10 @@ public class ResolverImpl implements Res
                     }
                     catch (ResolveException ex)
                     {
+                        if (rethrow == null)
+                        {
+                            rethrow = ex;
+                        }
                         // Remove the candidate since we weren't able to
                         // populate its candidates.
                         itCandCap.remove();
@@ -429,12 +434,15 @@ public class ResolverImpl implements Res
             // a resolve exception.
             if ((candidates.size() == 0) && !req.isOptional())
             {
-                ResolveException ex =
-                    new ResolveException("Unable to resolve " + module
-                        + ": missing requirement " + req, module, req);
-                resultCache.put(module, ex);
-                m_logger.log(Logger.LOG_DEBUG, "No viable candidates", ex);
-                throw ex;
+                if (rethrow == null)
+                {
+                    rethrow =
+                        new ResolveException("Unable to resolve " + module
+                            + ": missing requirement " + req, module, req);
+                }
+                resultCache.put(module, rethrow);
+                m_logger.log(Logger.LOG_DEBUG, "No viable candidates", rethrow);
+                throw rethrow;
             }
             // If we actually have candidates for the requirement, then
             // add them to the local candidate map.
@@ -470,6 +478,7 @@ public class ResolverImpl implements Res
         // There should be one entry in the candidate map, which are the
         // the candidates for the matching dynamic requirement. Get the
         // matching candidates and populate their candidates if necessary.
+        ResolveException rethrow = null;
         Entry<Requirement, Set<Capability>> entry = candidateMap.entrySet().iterator().next();
         Requirement dynReq = entry.getKey();
         Set<Capability> candidates = entry.getValue();
@@ -485,6 +494,10 @@ public class ResolverImpl implements Res
                 }
                 catch (ResolveException ex)
                 {
+                    if (rethrow == null)
+                    {
+                        rethrow = ex;
+                    }
                     itCandCap.remove();
                 }
             }
@@ -493,7 +506,11 @@ public class ResolverImpl implements Res
         if (candidates.size() == 0)
         {
             candidateMap.remove(dynReq);
-            throw new ResolveException("Dynamic import failed.", module, dynReq);
+            if (rethrow == null)
+            {
+                rethrow = new ResolveException("Dynamic import failed.", module, dynReq);
+            }
+            throw rethrow;
         }
     }
 



Mime
View raw message