Author: xavier
Date: Fri Dec  7 12:13:50 2007
New Revision: 602203

URL: http://svn.apache.org/viewvc?rev=602203&view=rev
Log:
FIX: latest compatible conflict manager fails with circular dependencies and 
dynamic revision (IVY-663)

Added:
    ant/ivy/core/trunk/test/repositories/2/mod6.3/mod6.3-1.0.jar   (with props)
    ant/ivy/core/trunk/test/repositories/2/mod6.3/mod6.3-1.2.jar   (with props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
    
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
    
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=602203&r1=602202&r2=602203&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Fri Dec  7 12:13:50 2007
@@ -59,6 +59,7 @@
 =====================================
 - IMPROVEMENT: Decrease memory footprint (IVY-662)
 
+- FIX: latest compatible conflict manager fails with circular dependencies and 
dynamic revision (IVY-663)
 - FIX: Strict conflictmanager seems to not support dynamic revisions (IVY-474)
 - FIX: NPE in namespace transformation during the ivy:findrevision and 
ivy:resolve task execution (IVY-659) (thanks to Andrea Bernardo Ciddio)
 

Modified: 
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java?rev=602203&r1=602202&r2=602203&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java 
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java 
Fri Dec  7 12:13:50 2007
@@ -585,7 +585,7 @@
             // indeed in some cases conflict manager need more information 
than just asked
             // dependency to take the decision
             resolveConflict(node, conf); 
-            if (!node.isEvicted()) {
+            if (!node.isEvicted() && !node.isCircular()) {
                 String[] confs = node.getRealConfs(conf);
                 for (int i = 0; i < confs.length; i++) {
                     doFetchDependencies(node, confs[i]);
@@ -594,7 +594,7 @@
         } else if (!node.hasProblem()) {
             // the node has not been loaded but hasn't problem: it was already 
loaded
             // => we just have to update its dependencies data
-            if (!node.isEvicted()) {
+            if (!node.isEvicted() && !node.isCircular()) {
                 String[] confs = node.getRealConfs(conf);
                 for (int i = 0; i < confs.length; i++) {
                     doFetchDependencies(node, confs[i]);
@@ -661,9 +661,6 @@
                 VisitNode dep = (VisitNode) iter.next();
                 dep.useRealNode(); // the node may have been resolved to 
another real one while
                 // resolving other deps
-                if (dep.isCircular()) {
-                    continue;
-                }
                 String[] confs = dep.getRequiredConfigurations(node, conf);
                 for (int i = 0; i < confs.length; i++) {
                     fetchDependencies(dep, confs[i], true);

Modified: 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java?rev=602203&r1=602202&r2=602203&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
 (original)
+++ 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
 Fri Dec  7 12:13:50 2007
@@ -237,8 +237,8 @@
             Stack/*<IvyNode>*/ callerStack) {
         Collection/*<IvyNodeBlacklist>*/ blacklisted = new 
ArrayList/*<IvyNodeBlacklist>*/();
         IvyNode node = (IvyNode) callerStack.peek();
-        Caller[] callers = node.getAllCallers();
         String rootModuleConf = 
conflictParent.getData().getReport().getConfiguration();
+        Caller[] callers = node.getCallers(rootModuleConf);
         for (int i = 0; i < callers.length; i++) {
             IvyNode callerNode = 
node.findNode(callers[i].getModuleRevisionId());
             if (callerNode.isBlacklisted(rootModuleConf)) {
@@ -248,12 +248,16 @@
                 blacklisted.add(new IvyNodeBlacklist(
                     conflictParent, selectedNode, evictedNode, node, 
rootModuleConf));
             } else {
-                if (callerNode == null) {
-                    // we have reached the root without finding a way to 
change the blacklist a
-                    // caller in a particular path, this is a strict conflict
-                    return null;
-                }
-                if (!callerStack.contains(callerNode)) {
+                if (callerStack.subList(0, callerStack.size() - 
1).contains(node)) {
+                    // circular dependency found and handled: the current top 
of the stack (node)
+                    // was already contained in the rest of the stack, the 
circle is closed, nothing
+                    // else to do
+                } else {
+                    if (callerNode == null) {
+                        // we have reached the root without finding a way to 
change the blacklist a
+                        // caller in a particular path, this is a strict 
conflict
+                        return null;
+                    }
                     callerStack.push(callerNode);
                     Collection sub = blackListIncompatibleCaller(
                         versionMatcher, conflictParent, selectedNode, 
evictedNode, callerStack);
@@ -264,13 +268,11 @@
                     } else {
                         blacklisted.addAll(sub);
                     }
-                } else {
-                    // circular dependency, nothing to do, this path should 
not be considered as a
-                    // problem
                 }
             }
         }
-        if (blacklisted.isEmpty()) {
+        if (blacklisted.isEmpty() 
+                && !callerStack.subList(0, callerStack.size() - 
1).contains(node)) {
             return null;
         }
         return blacklisted;

Modified: 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java?rev=602203&r1=602202&r2=602203&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java
 (original)
+++ 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java
 Fri Dec  7 12:13:50 2007
@@ -113,6 +113,16 @@
 
     public void testCompatibilityResolve6() throws Exception {
         fixture
+            .addMD("#A;1-> { #C;[2.0,2.5] #B;1.4 }")
+            .addMD("#B;1.4->#D;1.5")
+            .addMD("#C;2.5->#D;[1.0,1.6]")
+            .addMD("#D;1.5").addMD("#D;1.6")
+            .init();
+        resolveAndAssert("#A;1", "#B;1.4, #C;2.5, #D;1.5");
+    }
+
+    public void testCompatibilityResolveCircularDependency1() throws Exception 
{
+        fixture
             .addMD("#A;6->{ #B;[3.0,3.5] #C;4.6 }")
             .addMD("#B;3.4->#D;2.5")
             .addMD("#B;3.5->#D;3.0")
@@ -124,14 +134,31 @@
         resolveAndAssert("#A;6", "#B;3.4, #C;4.6, #D;2.5");
     }
 
-    public void testCompatibilityResolve7() throws Exception {
+    public void testCompatibilityResolveCircularDependency2() throws Exception 
{
         fixture
-            .addMD("#A;1-> { #C;[2.0,2.5] #B;1.4 }")
-            .addMD("#B;1.4->#D;1.5")
-            .addMD("#C;2.5->#D;[1.0,1.6]")
-            .addMD("#D;1.5").addMD("#D;1.6")
+            .addMD("#A;1->#C;2")
+            .addMD("#C;1->#B;1")
+            .addMD("#C;2->#B;2")
+            .addMD("#C;3->#B;3")
+            .addMD("#B;1->#C;latest.integration") // circular dependency
+            .addMD("#B;2->#C;latest.integration") // circular dependency
+            .addMD("#B;3->#C;latest.integration") // circular dependency
             .init();
-        resolveAndAssert("#A;1", "#B;1.4, #C;2.5, #D;1.5");
+        resolveAndAssert("#A;1", "#B;2, #C;2");
+    }
+
+    public void testCompatibilityResolveCircularDependency3() throws Exception 
{
+        // same as 2, but A depends on B
+        fixture
+            .addMD("#A;1->#B;2")
+            .addMD("#C;1->#B;1")
+            .addMD("#C;2->#B;2")
+            .addMD("#C;3->#B;3")
+            .addMD("#B;1->#C;latest.integration") // circular dependency
+            .addMD("#B;2->#C;latest.integration") // circular dependency
+            .addMD("#B;3->#C;latest.integration") // circular dependency
+            .init();
+        resolveAndAssert("#A;1", "#B;2, #C;2");
     }
 
 

Added: ant/ivy/core/trunk/test/repositories/2/mod6.3/mod6.3-1.0.jar
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/2/mod6.3/mod6.3-1.0.jar?rev=602203&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ant/ivy/core/trunk/test/repositories/2/mod6.3/mod6.3-1.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ant/ivy/core/trunk/test/repositories/2/mod6.3/mod6.3-1.2.jar
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/2/mod6.3/mod6.3-1.2.jar?rev=602203&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ant/ivy/core/trunk/test/repositories/2/mod6.3/mod6.3-1.2.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


Reply via email to