Author: mbenson
Date: Tue Jul 24 16:05:39 2007
New Revision: 559252

URL: http://svn.apache.org/viewvc?view=rev&rev=559252
Log:
Merge fix for Bugzilla 42967.


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

Modified: ant/core/branches/ANT_17_BRANCH/WHATSNEW
URL: 
http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/WHATSNEW?view=diff&rev=559252&r1=559251&r2=559252
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/WHATSNEW (original)
+++ ant/core/branches/ANT_17_BRANCH/WHATSNEW Tue Jul 24 16:05:39 2007
@@ -105,6 +105,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/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/Path.java
URL: 
http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/Path.java?view=diff&rev=559252&r1=559251&r2=559252
==============================================================================
--- 
ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/Path.java 
(original)
+++ 
ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/Path.java 
Tue Jul 24 16:05:39 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 Boolean preserveBC;
+
     private Union union = null;
 
     /**
@@ -684,6 +687,9 @@
             return ((Path) getCheckedRef()).iterator();
         }
         dieOnCircularReference();
+        if (getPreserveBC()) {
+            return new FileResourceIterator(null, list());
+        }
         return union == null ? EMPTY_ITERATOR
             : assertFilesystemOnly(union).iterator();
     }
@@ -713,5 +719,33 @@
                 + " 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 only once.
+     * @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;
+        }
+    }
+
+    private synchronized boolean getPreserveBC() {
+        if (preserveBC == null) {
+            preserveBC = delegateIteratorToList() ? Boolean.TRUE : 
Boolean.FALSE;
+        }
+        return preserveBC.booleanValue();
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to