Author: xavier
Date: Wed Nov 28 07:18:38 2007
New Revision: 599024

URL: http://svn.apache.org/viewvc?rev=599024&view=rev
Log:
fix issue with circular dependency and latest compatible conflict manager 
(IVY-648)

Added:
    
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-6.xml
   (with props)
    incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/
    incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/B.jar   
(with props)
    incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/ivy.xml  
 (with props)
    incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/
    incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/B.jar   
(with props)
    incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/ivy.xml  
 (with props)
    incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/
    incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/C.jar   
(with props)
    incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/ivy.xml  
 (with props)
    incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/
    incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/D.jar   
(with props)
    incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/ivy.xml  
 (with props)
    incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/
    incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/D.jar   
(with props)
    incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/ivy.xml  
 (with props)
Modified:
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
    
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
    
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java

Modified: 
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java?rev=599024&r1=599023&r2=599024&view=diff
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java 
(original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java 
Wed Nov 28 07:18:38 2007
@@ -1211,20 +1211,27 @@
             Message.verbose("BLACKLISTING " + bdata);
         }
         
-        clearEvictionDataInAllCallers(bdata.getRootModuleConf(), this);
+        Stack callerStack = new Stack();
+        callerStack.push(this);
+        clearEvictionDataInAllCallers(bdata.getRootModuleConf(), callerStack);
         
         blacklisted.put(bdata.getRootModuleConf(), bdata);
         data.blacklist(this);
     }
 
 
-    private void clearEvictionDataInAllCallers(String rootModuleConf, IvyNode 
node) {
+    private void clearEvictionDataInAllCallers(String rootModuleConf, 
Stack/*<IvyNode>*/ callerStack) {
+        IvyNode node = (IvyNode) callerStack.peek();
         Caller[] callers = node.getCallers(rootModuleConf);
         for (int i = 0; i < callers.length; i++) {
             IvyNode callerNode = findNode(callers[i].getModuleRevisionId());
             if (callerNode != null) {
                 callerNode.eviction = new IvyNodeEviction(callerNode);
-                clearEvictionDataInAllCallers(rootModuleConf, callerNode);
+                if (!callerStack.contains(callerNode)) {
+                    callerStack.push(callerNode);
+                    clearEvictionDataInAllCallers(rootModuleConf, callerStack);
+                    callerStack.pop();
+                }
             }
         }
     }

Modified: 
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java?rev=599024&r1=599023&r2=599024&view=diff
==============================================================================
--- 
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
 (original)
+++ 
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
 Wed Nov 28 07:18:38 2007
@@ -24,6 +24,7 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
+import java.util.Stack;
 
 import org.apache.ivy.core.IvyContext;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
@@ -183,8 +184,10 @@
 
     private void 
blackListIncompatibleCallerAndRestartResolveIfPossible(IvySettings settings,
             IvyNode parent, IvyNode selected, IvyNode evicted) {
+        Stack callerStack = new Stack();
+        callerStack.push(evicted);
         final Collection toBlacklist = blackListIncompatibleCaller(
-            settings.getVersionMatcher(), parent, selected, evicted, evicted); 
+            settings.getVersionMatcher(), parent, selected, evicted, 
callerStack); 
         if (toBlacklist != null) {
             final StringBuffer blacklisted = new StringBuffer();
             for (Iterator iterator = toBlacklist.iterator(); 
iterator.hasNext();) {
@@ -229,8 +232,10 @@
      */
     private Collection/*<IvyNodeBlacklist>*/ blackListIncompatibleCaller(
             VersionMatcher versionMatcher,
-            IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode, 
IvyNode node) {
+            IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode, 
+            Stack/*<IvyNode>*/ callerStack) {
         Collection/*<IvyNodeBlacklist>*/ blacklisted = new 
ArrayList/*<IvyNodeBlacklist>*/();
+        IvyNode node = (IvyNode) callerStack.peek();
         Caller[] callers = node.getAllCallers();
         String rootModuleConf = 
conflictParent.getData().getReport().getConfiguration();
         for (int i = 0; i < callers.length; i++) {
@@ -247,13 +252,20 @@
                     // caller in a particular path, this is a strict conflict
                     return null;
                 }
-                Collection sub = blackListIncompatibleCaller(
-                    versionMatcher, conflictParent, selectedNode, evictedNode, 
callerNode);
-                if (sub == null) {
-                    // propagate the fact that a path with unblacklistable 
caller has been found
-                    return null;
+                if (!callerStack.contains(callerNode)) {
+                    callerStack.push(callerNode);
+                    Collection sub = blackListIncompatibleCaller(
+                        versionMatcher, conflictParent, selectedNode, 
evictedNode, callerStack);
+                    callerStack.pop();
+                    if (sub == null) {
+                        // propagate the fact that a path with unblacklistable 
caller has been found
+                        return null;
+                    } else {
+                        blacklisted.addAll(sub);
+                    }
                 } else {
-                    blacklisted.addAll(sub);
+                    // circular dependency, nothing to do, this path should 
not be considered as a
+                    // problem
                 }
             }
         }

Modified: 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java?rev=599024&r1=599023&r2=599024&view=diff
==============================================================================
--- 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java
 (original)
+++ 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java
 Wed Nov 28 07:18:38 2007
@@ -100,13 +100,25 @@
 
     public void testCompatibilityResolve5() throws Exception {
         /* Test data:
-            #A;4->{ #B;[1.0,1.5] #C;2.6 }
+            #A;5->{ #B;[1.0,1.5] #C;2.6 }
             #B;1.3->{ }
             #B;1.4->#D;1.5
             #B;1.5->#D;2.0
             #C;2.6->#D;1.6
          */
         resolveAndAssert("ivy-latest-compatible-5.xml", "#B;1.3, #C;2.6, 
#D;1.6");
+    }
+
+    public void testCompatibilityResolve6() throws Exception {
+        /* Test data:
+            #A;6->{ #B;[3.0,3.5] #C;4.6 }
+            #B;3.4->#D;2.5
+            #B;3.5->#D;3.0
+            #C;4.6->#D;2.5
+            #D;3.0->#B;3.5 (circular dependency)
+            #D;2.5->#B;3.4 (circular dependency)
+         */
+        resolveAndAssert("ivy-latest-compatible-6.xml", "#B;3.4, #C;4.6, 
#D;2.5");
     }
 
 

Added: 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-6.xml
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-6.xml?rev=599024&view=auto
==============================================================================
--- 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-6.xml
 (added)
+++ 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-6.xml
 Wed Nov 28 07:18:38 2007
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivy-module version="1.0"> 
+        <info organisation="" module="A" revision="6" status="release"/>
+        <dependencies>
+            <dependency name="B" rev="[3.0,3.5]"/>
+            <dependency name="C" rev="4.6"/>
+        </dependencies>
+</ivy-module>

Propchange: 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-6.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/B.jar
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/B.jar?rev=599024&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/B.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/ivy.xml
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/ivy.xml?rev=599024&view=auto
==============================================================================
--- incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/ivy.xml 
(added)
+++ incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/ivy.xml 
Wed Nov 28 07:18:38 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivy-module version="1.0">
+    <info organisation="" module="B" revision="3.4" status="integration" />
+    <dependencies>
+       <dependency name="D" rev="2.5" />
+    </dependencies>
+</ivy-module>

Propchange: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.4/ivy.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/B.jar
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/B.jar?rev=599024&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/B.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/ivy.xml
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/ivy.xml?rev=599024&view=auto
==============================================================================
--- incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/ivy.xml 
(added)
+++ incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/ivy.xml 
Wed Nov 28 07:18:38 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivy-module version="1.0">
+    <info organisation="" module="B" revision="3.5" status="integration" />
+    <dependencies>
+       <dependency name="D" rev="3.0" />
+    </dependencies>
+</ivy-module>

Propchange: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/B/3.5/ivy.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/C.jar
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/C.jar?rev=599024&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/C.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/ivy.xml
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/ivy.xml?rev=599024&view=auto
==============================================================================
--- incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/ivy.xml 
(added)
+++ incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/ivy.xml 
Wed Nov 28 07:18:38 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivy-module version="1.0">
+    <info organisation="" module="C" revision="4.6" status="integration" />
+    <dependencies>
+       <dependency name="D" rev="2.5" />
+    </dependencies>
+</ivy-module>

Propchange: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/C/4.6/ivy.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/D.jar
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/D.jar?rev=599024&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/D.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/ivy.xml
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/ivy.xml?rev=599024&view=auto
==============================================================================
--- incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/ivy.xml 
(added)
+++ incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/ivy.xml 
Wed Nov 28 07:18:38 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivy-module version="1.0">
+    <info organisation="" module="D" revision="2.5" status="integration" />
+    <dependencies>
+       <dependency name="B" rev="3.4" />
+    </dependencies>
+</ivy-module>

Propchange: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/D/2.5/ivy.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/D.jar
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/D.jar?rev=599024&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/D.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/ivy.xml
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/ivy.xml?rev=599024&view=auto
==============================================================================
--- incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/ivy.xml 
(added)
+++ incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/ivy.xml 
Wed Nov 28 07:18:38 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivy-module version="1.0">
+    <info organisation="" module="D" revision="3.0" status="integration" />
+    <dependencies>
+       <dependency name="B" rev="3.5" />
+    </dependencies>
+</ivy-module>

Propchange: 
incubator/ivy/core/trunk/test/repositories/latest-compatible/D/3.0/ivy.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to