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

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

commit 382edda47687bf2eec6f65f0f17e29e81b7cf847
Author: jkf <[email protected]>
AuthorDate: Sat Jun 1 14:18:52 2019 +0200

    Patch improving FTP Connection Closed error handling and reporting by
    Eugene Adell
---
 .../apache/tools/ant/taskdefs/optional/net/FTP.java    | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

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 6ac22c8..ee3d30b 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
@@ -45,6 +45,7 @@ import org.apache.commons.net.ftp.FTPClient;
 import org.apache.commons.net.ftp.FTPClientConfig;
 import org.apache.commons.net.ftp.FTPFile;
 import org.apache.commons.net.ftp.FTPReply;
+import org.apache.commons.net.ftp.FTPConnectionClosedException;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.Project;
@@ -546,6 +547,9 @@ public class FTP extends Task implements FTPTaskConfig {
                     }
                 }
                 ftp.changeToParentDirectory();
+            } catch (FTPConnectionClosedException ftpcce) {
+                throw new BuildException("Error while communicating with FTP "
+                                         + "server: ", ftpcce);
             } catch (IOException e) {
                 throw new BuildException("Error while communicating with FTP "
                                          + "server: ", e);
@@ -1138,7 +1142,7 @@ public class FTP extends Task implements FTPTaskConfig {
      * @return true if it is possible to cd to this directory
      * @since ant 1.6
      */
-    private boolean isFunctioningAsDirectory(FTPClient ftp, String dir, 
FTPFile file) {
+    private boolean isFunctioningAsDirectory(FTPClient ftp, String dir, 
FTPFile file) throws FTPConnectionClosedException {
         if (file.isDirectory()) {
             return true;
         }
@@ -1148,6 +1152,11 @@ public class FTP extends Task implements FTPTaskConfig {
         String currentWorkingDir = null;
         try {
             currentWorkingDir = ftp.printWorkingDirectory();
+        } catch (FTPConnectionClosedException ftpcce) {
+            getProject().log("could not find current working directory " + dir
+                             + " while checking a symlink because connection 
was closed",
+                             Project.MSG_DEBUG);
+            throw(ftpcce);
         } catch (IOException ioe) {
             getProject().log("could not find current working directory " + dir
                              + " while checking a symlink",
@@ -1157,6 +1166,11 @@ public class FTP extends Task implements FTPTaskConfig {
         if (currentWorkingDir != null) {
             try {
                 result = ftp.changeWorkingDirectory(file.getLink());
+            } catch (FTPConnectionClosedException ftpcce) {
+                getProject().log("could not find current working directory " + 
dir
+                                + " while checking a symlink because 
connection was closed",
+                                Project.MSG_DEBUG);
+                throw(ftpcce);
             } catch (IOException ioe) {
                 getProject().log("could not cd to " + file.getLink() + " while 
checking a symlink",
                                  Project.MSG_DEBUG);
@@ -1189,7 +1203,7 @@ public class FTP extends Task implements FTPTaskConfig {
      * @return true if it is possible to cd to this directory
      * @since ant 1.6
      */
-    private boolean isFunctioningAsFile(FTPClient ftp, String dir, FTPFile 
file) {
+    private boolean isFunctioningAsFile(FTPClient ftp, String dir, FTPFile 
file) throws FTPConnectionClosedException {
         return !file.isDirectory() && (file.isFile() || 
!isFunctioningAsDirectory(ftp, dir, file));
     }
 

Reply via email to