This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git


The following commit(s) were added to refs/heads/master by this push:
     new f862774a9 bz-69485 Revert the foreach loop change that was done to 
FTPTaskMirrorImpl in 1c80d507f496dde98869890e671edf635bef8dec
f862774a9 is described below

commit f862774a9e2d2afe3d25d7116f0672eeb4f3e9bf
Author: Jaikiran Pai <[email protected]>
AuthorDate: Thu Dec 25 15:18:33 2025 +0530

    bz-69485 Revert the foreach loop change that was done to FTPTaskMirrorImpl 
in 1c80d507f496dde98869890e671edf635bef8dec
---
 .../tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java       | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git 
a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java 
b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
index 3d45cb105..636f54783 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
@@ -724,7 +724,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 } catch (IOException ioe) {
                     throw new BuildException("could not change working dir to 
%s", parent.curpwd);
                 }
-                for (String currentPathElement : pathElements) {
+                final int size = pathElements.size();
+                for (int fcount = 0; fcount < size - 1; fcount++) {
+                    String currentPathElement = pathElements.get(fcount);
                     try {
                         if 
(!this.client.changeWorkingDirectory(currentPathElement)) {
                             if (!isCaseSensitive() && 
(remoteSystemCaseSensitive
@@ -743,8 +745,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                                 currentPathElement, this.curpwd);
                     }
                 }
-                String lastpathelement = pathElements.get(pathElements.size() 
- 1);
-                this.ftpFile = getFile(listFiles(this.curpwd), 
lastpathelement);
+                String lastpathelement = pathElements.get(size - 1);
+                FTPFile[] theFiles = listFiles(this.curpwd);
+                this.ftpFile = getFile(theFiles, lastpathelement);
             }
             /**
              * find a file in a directory in case insensitive way

Reply via email to