Browse Source

Regression: Path subclasses that overrode list() stopped working in

resourceCollection contexts in Ant 1.7.0. Bugzilla 42967.



git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@559096 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 18 years ago
parent
commit
e413801422
2 changed files with 31 additions and 0 deletions
  1. +3
    -0
      WHATSNEW
  2. +28
    -0
      src/main/org/apache/tools/ant/types/Path.java

+ 3
- 0
WHATSNEW View File

@@ -124,6 +124,9 @@ Fixed bugs:
* Modified selector doesn't update the cache if only one file has changed.
Bugzilla 42802.

* Regression: Path subclasses that overrode list() stopped working in
resourceCollection contexts in Ant 1.7.0. Bugzilla 42967.

Other changes:
--------------
* <script> now has basic support for JavaFX scripts


+ 28
- 0
src/main/org/apache/tools/ant/types/Path.java View File

@@ -19,6 +19,7 @@
package org.apache.tools.ant.types;

import java.io.File;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Iterator;
import java.util.Locale;
@@ -141,6 +142,8 @@ public class Path extends DataType implements Cloneable, ResourceCollection {

}

private final boolean preserveBC = delegateIteratorToList();

private Union union = null;

/**
@@ -684,6 +687,9 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
return ((Path) getCheckedRef()).iterator();
}
dieOnCircularReference();
if (preserveBC) {
return new FileResourceIterator(null, list());
}
return union == null ? EMPTY_ITERATOR
: assertFilesystemOnly(union).iterator();
}
@@ -714,4 +720,26 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
}
return rc;
}

/**
* Helps determine whether to preserve BC by calling <code>list()</code> on subclasses.
* The default behavior of this method is to return <code>true</code> for any subclass
* that implements <code>list()</code>; this can, of course, be avoided by overriding
* this method to return <code>false</code>. It is not expected that the result of this
* method should change over time; thus it is called a single time during instance
* initialization.
* @return <code>true</code> if <code>iterator()</code> should delegate to <code>list()</code>.
*/
protected boolean delegateIteratorToList() {
if (getClass().equals(Path.class)) {
return false;
}
try {
Method listMethod = getClass().getMethod("list", (Class[]) null);
return !listMethod.getDeclaringClass().equals(Path.class);
} catch (Exception e) {
//shouldn't happen, but
return false;
}
}
}

Loading…
Cancel
Save