Cool. Antoine -------- Original-Nachricht -------- Datum: Wed, 01 Nov 2006 22:35:10 -0000 Von: [EMAIL PROTECTED] An: [EMAIL PROTECTED] Betreff: svn commit: r470125 - in /ant/core/trunk/src: main/org/apache/tools/ant/types/Path.java tests/junit/org/apache/tools/ant/types/PathTest.java
> Author: jglick > Date: Wed Nov 1 14:35:09 2006 > New Revision: 470125 > > URL: http://svn.apache.org/viewvc?view=rev&rev=470125 > Log: > If someone tries to append a path to itself, choke gracefully, not with a > StackOverflowError. > > Modified: > ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java > > ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/PathTest.java > > Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java > URL: > http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java?view=diff&rev=470125&r1=470124&r2=470125 > ============================================================================== > --- ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java > (original) > +++ ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java Wed Nov > 1 14:35:09 2006 > @@ -19,7 +19,6 @@ > package org.apache.tools.ant.types; > > import java.io.File; > -import java.util.Collection; > import java.util.Collections; > import java.util.Iterator; > import java.util.Locale; > @@ -238,6 +237,9 @@ > * @since Ant 1.6 > */ > public void add(Path path) throws BuildException { > + if (path == this) { > + throw circularReference(); > + } > if (path.getProject() == null) { > path.setProject(getProject()); > } > > Modified: > ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/PathTest.java > URL: > http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/PathTest.java?view=diff&rev=470125&r1=470124&r2=470125 > ============================================================================== > --- > ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/PathTest.java > (original) > +++ > ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/PathTest.java Wed > Nov 1 14:35:09 2006 > @@ -549,4 +549,15 @@ > assertEquals(project.resolveFile("build").getAbsolutePath(), > l[0]); > } > > + public void testRecursion() { > + Path p = new Path(project); > + try { > + p.append(p); > + assertEquals(0, p.list().length); > + } catch (BuildException x) { > + String m = x.toString(); > + assertTrue(m, m.indexOf("circular") != -1); > + } > + } > + > } > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]