Author: maartenc
Date: Tue Aug 30 21:15:03 2011
New Revision: 1163390

URL: http://svn.apache.org/viewvc?rev=1163390&view=rev
Log:
FIX: Infinite loop in latest-compatible conflict manager (IVY-1233) (thanks to 
Payam Hekmat)

Added:
    ant/ivy/core/trunk/test/repositories/IVY-1233/
    ant/ivy/core/trunk/test/repositories/IVY-1233/ivy.xml
    ant/ivy/core/trunk/test/repositories/IVY-1233/ivysettings.xml
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.0/
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.0/ivy.xml
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.1/
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.1/ivy.xml
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.0/
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.0/ivy.xml
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.1/
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.1/ivy.xml
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.0/
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.0/ivy.xml
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.1/
    ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.1/ivy.xml
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1163390&r1=1163389&r2=1163390&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue Aug 30 21:15:03 2011
@@ -52,6 +52,7 @@ for detailed view of each issue, please 
        Ben Hale
        Peter Hayes
        Scott Hebert
+       Payam Hekmat
        Achim Huegen
        Matt Inger
        Anders Jacobsson
@@ -136,6 +137,7 @@ for detailed view of each issue, please 
 - IMPROVEMENT: ivy:retrieve can now convert 'dotted'-organisation names into a 
directory tree.
 - IMPROVEMENT: ivy:retrieve now accepts a nested mapper type.
 
+- FIX: Infinite loop in latest-compatible conflict manager (IVY-1233) (thanks 
to Payam Hekmat)
 - FIX: extends section of ivy.xml info does not replace variable in location 
tag (IVY-1287) (thanks to Jean-Louis Boudart)
 - FIX: Valid Path does not work for Filesystem Resolver (IVY-1268)
 - FIX: quiet="true" does not surpress download 'dots' on packager resolver 
(IVY-1269)

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=1163390&r1=1163389&r2=1163390&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
 Tue Aug 30 21:15:03 2011
@@ -188,7 +188,7 @@ public class LatestCompatibleConflictMan
         Stack callerStack = new Stack();
         callerStack.push(evicted);
         final Collection toBlacklist = blackListIncompatibleCaller(
-            settings.getVersionMatcher(), parent, selected, evicted, 
callerStack); 
+            settings.getVersionMatcher(), parent, selected, evicted, 
callerStack, false); 
         if (toBlacklist != null) {
             final StringBuffer blacklisted = new StringBuffer();
             for (Iterator iterator = toBlacklist.iterator(); 
iterator.hasNext();) {
@@ -215,6 +215,29 @@ public class LatestCompatibleConflictMan
         }
     }
 
+    private boolean handleIncompatibleCaller(Stack callerStack, IvyNode node, 
IvyNode callerNode,
+            IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode,
+            Collection blacklisted, VersionMatcher versionMatcher, boolean 
dynamicCaller) {
+        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
+            return true;
+        } else {
+            callerStack.push(callerNode);
+            Collection sub = blackListIncompatibleCaller(versionMatcher, 
conflictParent,
+                selectedNode, evictedNode, callerStack, dynamicCaller);
+            callerStack.pop();
+            if (sub == null) {
+                // propagate the fact that a path with unblacklistable caller 
has been found
+                return false;
+            } else {
+                blacklisted.addAll(sub);
+                return true;
+            }
+        }
+    }
+
     /**
      * Tries to blacklist exactly one version for all callers paths.
      * 
@@ -234,7 +257,8 @@ public class LatestCompatibleConflictMan
     private Collection/*<IvyNodeBlacklist>*/ blackListIncompatibleCaller(
             VersionMatcher versionMatcher,
             IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode, 
-            Stack/*<IvyNode>*/ callerStack) {
+            Stack/*<IvyNode>*/ callerStack,
+            boolean dynamicCaller) {
         Collection/*<IvyNodeBlacklist>*/ blacklisted = new 
ArrayList/*<IvyNodeBlacklist>*/();
         IvyNode node = (IvyNode) callerStack.peek();
         String rootModuleConf = 
conflictParent.getData().getReport().getConfiguration();
@@ -245,28 +269,19 @@ public class LatestCompatibleConflictMan
                 continue;
             }
             if 
(versionMatcher.isDynamic(callers[i].getAskedDependencyId(node.getData()))) {
-                blacklisted.add(new IvyNodeBlacklist(
-                    conflictParent, selectedNode, evictedNode, node, 
rootModuleConf));
-            } else {
-                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 {
-                    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);
-                    }
+                blacklisted.add(new IvyNodeBlacklist(conflictParent, 
selectedNode, evictedNode,
+                        node, rootModuleConf));
+                if (node.isEvicted(rootModuleConf)
+                        && !handleIncompatibleCaller(callerStack, node, 
callerNode, conflictParent,
+                            selectedNode, evictedNode, blacklisted, 
versionMatcher, true)) {
+                    return null;
                 }
+            } else if(!handleIncompatibleCaller(callerStack, node, callerNode, 
conflictParent,
+                    selectedNode, evictedNode, blacklisted, versionMatcher, 
false)) {
+                return null;
             }
         }
-        if (blacklisted.isEmpty() 
+        if (!dynamicCaller && blacklisted.isEmpty() 
                 && !callerStack.subList(0, callerStack.size() - 
1).contains(node)) {
             return null;
         }

Modified: 
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=1163390&r1=1163389&r2=1163390&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java 
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java 
Tue Aug 30 21:15:03 2011
@@ -3365,6 +3365,21 @@ public class ResolveTest extends TestCas
         assertTrue(getArchiveFileInCache("myorg", "modB", "1.0", "modB-A", 
"jar", "jar").exists());
     }
 
+    public void testIVY1233() throws Exception {
+        Ivy ivy = new Ivy();
+        ivy.configure(new File("test/repositories/IVY-1233/ivysettings.xml"));
+        ivy.getSettings().setDefaultCache(cache);
+
+        ResolveReport rr = ivy.resolve(new 
File("test/repositories/IVY-1233/ivy.xml").toURI().toURL(),
+            getResolveOptions(new String[] {"*"}));
+        ConfigurationResolveReport crr = rr.getConfigurationReport("default");
+        Set modRevIds = crr.getModuleRevisionIds();
+        assertEquals(3, modRevIds.size());
+        assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("test", 
"a", "1.0")));
+        assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("test", 
"b", "2.0")));
+        assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("test", 
"c", "3.0")));
+    }
+
     public void testIVY999() throws Exception {
         Ivy ivy = new Ivy();
         ivy.configure(new File("test/repositories/IVY-999/ivysettings.xml"));

Added: ant/ivy/core/trunk/test/repositories/IVY-1233/ivy.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1233/ivy.xml?rev=1163390&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1233/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1233/ivy.xml Tue Aug 30 21:15:03 
2011
@@ -0,0 +1,27 @@
+<!--
+   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="2.0">
+       <info organisation="test" module="test" />
+       <dependencies>
+               <dependency org="test" name="a" rev="1.+" />
+               <dependency org="test" name="b" rev="2.+" />
+               <dependency org="test" name="c" rev="3.+" />
+       </dependencies>
+</ivy-module>
+

Added: ant/ivy/core/trunk/test/repositories/IVY-1233/ivysettings.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1233/ivysettings.xml?rev=1163390&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1233/ivysettings.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1233/ivysettings.xml Tue Aug 30 
21:15:03 2011
@@ -0,0 +1,27 @@
+<!--
+   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.
+-->
+<ivysettings>
+    <settings defaultResolver="test" 
defaultConflictManager="latest-compatible"/>
+    <resolvers>
+        <filesystem name="test">
+            <ivy 
pattern="${ivy.settings.dir}/[organisation]/[module]/[revision]/ivy.xml" />
+            <artifact 
pattern="${ivy.settings.dir}/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
 />
+        </filesystem>
+    </resolvers>
+</ivysettings>

Added: ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.0/ivy.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.0/ivy.xml?rev=1163390&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.0/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.0/ivy.xml Tue Aug 30 
21:15:03 2011
@@ -0,0 +1,23 @@
+<!--
+   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="2.0">
+       <info organisation="test" module="a" revision="1.0" 
publication="20100702134716" />
+       <publications />
+       <dependencies />
+</ivy-module>
\ No newline at end of file

Added: ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.1/ivy.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.1/ivy.xml?rev=1163390&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.1/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1233/test/a/1.1/ivy.xml Tue Aug 30 
21:15:03 2011
@@ -0,0 +1,23 @@
+<!--
+   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="2.0">
+       <info organisation="test" module="a" revision="1.1" 
publication="20100702134716" />
+       <publications />
+       <dependencies />
+</ivy-module>
\ No newline at end of file

Added: ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.0/ivy.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.0/ivy.xml?rev=1163390&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.0/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.0/ivy.xml Tue Aug 30 
21:15:03 2011
@@ -0,0 +1,25 @@
+<!--
+   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="2.0">
+       <info organisation="test" module="b" revision="2.0" 
publication="20100702134716" />
+       <publications />
+       <dependencies>
+               <dependency org="test" name="a" rev="1.0" />
+       </dependencies>
+</ivy-module>
\ No newline at end of file

Added: ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.1/ivy.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.1/ivy.xml?rev=1163390&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.1/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1233/test/b/2.1/ivy.xml Tue Aug 30 
21:15:03 2011
@@ -0,0 +1,25 @@
+<!--
+   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="2.0">
+       <info organisation="test" module="b" revision="2.1" 
publication="20100702134716" />
+       <publications />
+       <dependencies>
+               <dependency org="test" name="a" rev="1.0" />
+       </dependencies>
+</ivy-module>
\ No newline at end of file

Added: ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.0/ivy.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.0/ivy.xml?rev=1163390&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.0/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.0/ivy.xml Tue Aug 30 
21:15:03 2011
@@ -0,0 +1,26 @@
+<!--
+   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="2.0">
+       <info organisation="test" module="c" revision="3.0" 
publication="20100702134716" />
+       <publications />
+       <dependencies>
+               <dependency org="test" name="a" rev="1.0" />
+               <dependency org="test" name="b" rev="2.0" />
+       </dependencies>
+</ivy-module>
\ No newline at end of file

Added: ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.1/ivy.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.1/ivy.xml?rev=1163390&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.1/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1233/test/c/3.1/ivy.xml Tue Aug 30 
21:15:03 2011
@@ -0,0 +1,26 @@
+<!--
+   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="2.0">
+       <info organisation="test" module="c" revision="3.1" 
publication="20100702134716" />
+       <publications />
+       <dependencies>
+               <dependency org="test" name="a" rev="[1.1,1.2]" />
+               <dependency org="test" name="b" rev="2.1" />
+       </dependencies>
+</ivy-module>
\ No newline at end of file


Reply via email to