ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r559096 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/types/Path.java
Date Tue, 24 Jul 2007 16:32:14 GMT
Author: mbenson
Date: Tue Jul 24 09:32:09 2007
New Revision: 559096

URL: http://svn.apache.org/viewvc?view=rev&rev=559096
Log:
Regression: Path subclasses that overrode list() stopped working in
resourceCollection contexts in Ant 1.7.0. Bugzilla 42967.


Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=559096&r1=559095&r2=559096
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Jul 24 09:32:09 2007
@@ -124,6 +124,9 @@
 * 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

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=559096&r1=559095&r2=559096
==============================================================================
--- 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 Tue Jul 24 09:32:09 2007
@@ -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 @@
 
     }
 
+    private final boolean preserveBC = delegateIteratorToList();
+
     private Union union = null;
 
     /**
@@ -684,6 +687,9 @@
             return ((Path) getCheckedRef()).iterator();
         }
         dieOnCircularReference();
+        if (preserveBC) {
+            return new FileResourceIterator(null, list());
+        }
         return union == null ? EMPTY_ITERATOR
             : assertFilesystemOnly(union).iterator();
     }
@@ -713,5 +719,27 @@
                 + " allows only filesystem resources.");
         }
         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;
+        }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message