You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by xa...@apache.org on 2008/03/04 18:49:13 UTC
svn commit: r633568 - in /ant/ivy/core/trunk: ./
src/java/org/apache/ivy/core/module/descriptor/
test/java/org/apache/ivy/plugins/parser/xml/
Author: xavier
Date: Tue Mar 4 09:49:10 2008
New Revision: 633568
URL: http://svn.apache.org/viewvc?rev=633568&view=rev
Log:
FIX: StackOverflowError when configuration extends itself (IVY-696)
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs1.xml (with props)
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs2.xml (with props)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=633568&r1=633567&r2=633568&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue Mar 4 09:49:10 2008
@@ -70,6 +70,7 @@
- IMPROVEMENT: Make Ivy standalone runnable with no required dependencies (IVY-757)
- IMPROVEMENT: add branch attribute in ivy:install task (IVY-727)
+- FIX: StackOverflowError when configuration extends itself (IVY-696)
- FIX: XML schema ambiguity (IVY-750)
- FIX: ivy-resolve fails when a project has different dependencies in different branches (IVY-717)
- FIX: PublishEventsTest fails when Ivy sources are located in a directory with a + (IVY-755)
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java?rev=633568&r1=633567&r2=633568&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java Tue Mar 4 09:49:10 2008
@@ -31,6 +31,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Stack;
import org.apache.ivy.core.module.id.ArtifactId;
import org.apache.ivy.core.module.id.ModuleId;
@@ -511,19 +512,43 @@
}
/**
- * Throws an exception if the module descriptor is inconsistent For the moment, only extended
- * configurations existence is checked
+ * Throws an exception if the module descriptor is inconsistent
+ * For the moment, only extended configurations existence and cycles are checked
*/
public void check() {
+ Stack confs = new Stack();
for (Iterator iter = configurations.values().iterator(); iter.hasNext();) {
Configuration conf = (Configuration) iter.next();
String[] ext = conf.getExtends();
for (int i = 0; i < ext.length; i++) {
- if (!configurations.containsKey(ext[i].trim())) {
- throw new IllegalStateException("unknown configuration '" + ext[i]
- + "'. It is extended by " + conf.getName());
- }
+ confs.push(conf.getName());
+ checkConf(confs, ext[i].trim());
+ confs.pop();
+ }
+ }
+ }
+
+ private void checkConf(Stack confs, String confName) {
+ int index = confs.indexOf(confName);
+ if (index != -1) {
+ StringBuffer cycle = new StringBuffer();
+ for (; index < confs.size(); index++) {
+ cycle.append(confs.get(index)).append(" => ");
}
+ cycle.append(confName);
+ throw new IllegalStateException(
+ "illegal cycle detected in configuration extension: " + cycle);
+ }
+ Configuration conf = getConfiguration(confName);
+ if (conf == null) {
+ throw new IllegalStateException("unknown configuration '" + confName
+ + "'. It is extended by " + confs.get(confs.size() - 1));
+ }
+ String[] ext = conf.getExtends();
+ for (int i = 0; i < ext.length; i++) {
+ confs.push(conf.getName());
+ checkConf(confs, ext[i].trim());
+ confs.pop();
}
}
Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java?rev=633568&r1=633567&r2=633568&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java Tue Mar 4 09:49:10 2008
@@ -147,8 +147,28 @@
getClass().getResource("test-bad-confs.xml"), true);
fail("bad ivy file raised no error");
} catch (ParseException ex) {
+ ex.printStackTrace();
assertTrue("invalid exception: " + ex.getMessage(), ex.getMessage().indexOf(
"invalidConf") != -1);
+ }
+ }
+
+ public void testCyclicConfs() throws IOException {
+ try {
+ XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
+ getClass().getResource("test-cyclic-confs1.xml"), true);
+ fail("bad ivy file raised no error");
+ } catch (ParseException ex) {
+ assertTrue("invalid exception: " + ex.getMessage(), ex.getMessage().indexOf(
+ "A => B => A") != -1);
+ }
+ try {
+ XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
+ getClass().getResource("test-cyclic-confs2.xml"), true);
+ fail("bad ivy file raised no error");
+ } catch (ParseException ex) {
+ assertTrue("invalid exception: " + ex.getMessage(), ex.getMessage().indexOf(
+ "A => C => B => A") != -1);
}
}
Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs1.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs1.xml?rev=633568&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs1.xml (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs1.xml Tue Mar 4 09:49:10 2008
@@ -0,0 +1,28 @@
+<!--
+ 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="myorg"
+ module="mymodule"
+ status="integration"
+ />
+ <configurations>
+ <conf name="A" extends="B"/>
+ <conf name="B" extends="A"/>
+ </configurations>
+</ivy-module>
Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs1.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs1.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs2.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs2.xml?rev=633568&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs2.xml (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs2.xml Tue Mar 4 09:49:10 2008
@@ -0,0 +1,29 @@
+<!--
+ 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="myorg"
+ module="mymodule"
+ status="integration"
+ />
+ <configurations>
+ <conf name="A" extends="C"/>
+ <conf name="B" extends="A"/>
+ <conf name="C" extends="B"/>
+ </configurations>
+</ivy-module>
Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs2.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-cyclic-confs2.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain