Repository: ant
Updated Branches:
  refs/heads/master 2f0c40bc2 -> 110081eef


Add null guard, refactor loop

Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/110081ee
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/110081ee
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/110081ee

Branch: refs/heads/master
Commit: 110081eeff5af8a5a8a4f7972a6bf86811ecf2f5
Parents: 2f0c40b
Author: Gintas Grigelionis <gin...@apache.org>
Authored: Wed Apr 11 18:40:23 2018 +0200
Committer: Gintas Grigelionis <gin...@apache.org>
Committed: Wed Apr 11 18:40:23 2018 +0200

----------------------------------------------------------------------
 .../org/apache/tools/ant/taskdefs/optional/net/FTP.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/110081ee/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java 
b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
index 75f82c0..029e2d9 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
@@ -956,11 +956,10 @@ public class FTP extends Task implements FTPTaskConfig {
              */
             private String getRelativePath(String currentPath, String 
currentRelativePath) {
                 List<String> pathElements = 
SelectorUtils.tokenizePath(getAbsolutePath(), remoteFileSep);
-                List<String> pathElements2 = 
SelectorUtils.tokenizePath(currentPath, remoteFileSep);
-                StringBuilder relPath = new StringBuilder(currentRelativePath);
-                final int size = pathElements.size();
-                for (int pcount = pathElements2.size(); pcount < size; 
pcount++) {
-                    String currentElement = pathElements.get(pcount);
+                StringBuilder relPath = new StringBuilder(currentRelativePath 
== null
+                        ? "" : currentRelativePath);
+                for (String currentElement : 
pathElements.subList(SelectorUtils.tokenizePath(currentPath,
+                        remoteFileSep).size(), pathElements.size())) {
                     FTPFile[] theFiles = listFiles(currentPath);
                     FTPFile theFile = null;
                     if (theFiles != null) {
@@ -973,8 +972,7 @@ public class FTP extends Task implements FTPTaskConfig {
                         // hit a hidden file assume not a symlink
                         relPath.append(currentElement);
                         currentPath += remoteFileSep + currentElement;
-                        log("Hidden file " + relPath
-                            + " assumed to not be a symlink.",
+                        log("Hidden file " + relPath + " assumed to not be a 
symlink.",
                             Project.MSG_VERBOSE);
                     } else {
                         traversesSymlinks = traversesSymlinks || 
theFile.isSymbolicLink();

Reply via email to