FIX: Out of memory/Stack overflow for new highly coupled project (IVY-595)

git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@642199 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Xavier Hanin 2008-03-28 11:11:06 +00:00
parent b0d32e4b79
commit bc4d178e96
7 changed files with 149 additions and 3 deletions

View File

@ -75,6 +75,7 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br
- IMPROVEMENT: Parse description and home page from poms (IVY-767)
- IMPROVEMENT: Smarter determination if an expression is exact or not for RegexpPatternMatcher and GlobPatternMatcher
- FIX: Out of memory/Stack overflow for new highly coupled project (IVY-595)
- FIX: Compatibility with maven's dependencyMangement (IVY-753) (not completed yet)
- FIX: ivy:settings fails when override is not set to 'true' (IVY-771)
- FIX: NPE when specifying both resolveId and inline in an Ivy:Resolve (IVY-776)

View File

@ -357,10 +357,13 @@ public class IvyBuildList extends IvyTask {
DependencyDescriptor[] deps = node.getDependencies();
for (int i = 0; i < deps.length; i++) {
ModuleId id = deps[i].getDependencyId();
if (moduleIdMap.get(id) != null) {
toKeep.add(moduleIdMap.get(id));
ModuleDescriptor md = (ModuleDescriptor) moduleIdMap.get(id);
// we test if this module id has a module descriptor, and if it isn't already in the
// toKeep Set, in which there's probably a circular dependency
if (md != null && !toKeep.contains(md)) {
toKeep.add(md);
if (!getOnlydirectdep()) {
processFilterNodeFromRoot((ModuleDescriptor) moduleIdMap.get(id), toKeep,
processFilterNodeFromRoot(md, toKeep,
moduleIdMap);
}
}

View File

@ -0,0 +1,18 @@
<!--
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.
-->

24
test/buildlist/F/ivy.xml Normal file
View File

@ -0,0 +1,24 @@
<!--
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.2">
<info organisation="apache" module="F"/>
<dependencies>
<dependency name="G" rev="latest.integration"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,18 @@
<!--
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.
-->

24
test/buildlist/G/ivy.xml Normal file
View File

@ -0,0 +1,24 @@
<!--
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.2">
<info organisation="apache" module="G"/>
<dependencies>
<dependency name="F" rev="latest.integration"/>
</dependencies>
</ivy-module>

View File

@ -35,6 +35,8 @@ public class IvyBuildListTest extends TestCase {
* C -> B
* D -> A , B
* E has no dependency
* F -> G
* G -> F
*/
//CheckStyle:MagicNumber| OFF
@ -50,6 +52,7 @@ public class IvyBuildListTest extends TestCase {
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("F/build.xml,G/build.xml");
buildlist.addFileset(fs);
buildlist.setReference("ordered.build.files");
@ -88,6 +91,7 @@ public class IvyBuildListTest extends TestCase {
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("F/build.xml,G/build.xml");
buildlist.addFileset(fs);
buildlist.setReference("reverse.ordered.build.files");
@ -148,6 +152,32 @@ public class IvyBuildListTest extends TestCase {
.getAbsolutePath());
}
public void testWithRootCircular() {
Project p = new Project();
IvyBuildList buildlist = new IvyBuildList();
buildlist.setProject(p);
buildlist.setRoot("F");
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
buildlist.addFileset(fs);
buildlist.setReference("ordered.build.files");
buildlist.execute();
Object o = p.getReference("ordered.build.files");
assertNotNull(o);
assertTrue(o instanceof Path);
Path path = (Path) o;
String[] files = path.list();
assertNotNull(files);
assertEquals(2, files.length); // F and G should be in the list
}
public void testWithTwoRoots() {
Project p = new Project();
@ -282,6 +312,33 @@ public class IvyBuildListTest extends TestCase {
.getAbsolutePath());
}
public void testWithLeafCircular() {
Project p = new Project();
IvyBuildList buildlist = new IvyBuildList();
buildlist.setProject(p);
buildlist.setLeaf("F");
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
buildlist.addFileset(fs);
buildlist.setReference("ordered.build.files");
buildlist.execute();
Object o = p.getReference("ordered.build.files");
assertNotNull(o);
assertTrue(o instanceof Path);
Path path = (Path) o;
String[] files = path.list();
assertNotNull(files);
assertEquals(2, files.length);
}
public void testWithTwoLeafs() {
Project p = new Project();
@ -395,6 +452,7 @@ public class IvyBuildListTest extends TestCase {
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("F/build.xml,G/build.xml");
buildlist.addFileset(fs);
buildlist.setReference("ordered.build.files");