You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jk...@apache.org on 2019/07/12 14:09:13 UTC

[ant] branch master updated (1d7bf5c -> 1702b68)

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

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


    from 1d7bf5c  Merge branch '1.9.x'
     new e6b4417  Bug 47414 - [PATCH] Add Ftp ant task timeout by Eugene Adell
     new 1702b68  Add Ftp ant task timeout documentation also updated

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 manual/Tasks/ftp.html                              |  8 ++++-
 .../tools/ant/taskdefs/optional/net/FTP.java       | 37 ++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)


[ant] 01/02: Bug 47414 - [PATCH] Add Ftp ant task timeout by Eugene Adell

Posted by jk...@apache.org.
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 e6b44170a8419f01a5ea45b4917f569ca45aafff
Author: jkf <jm...@famkruithof.net>
AuthorDate: Fri Jul 12 14:45:48 2019 +0200

    Bug 47414 - [PATCH] Add Ftp ant task timeout by Eugene Adell
---
 .../tools/ant/taskdefs/optional/net/FTP.java       | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

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 ee3d30b..3be911a 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
@@ -25,6 +25,7 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.SocketTimeoutException;
 import java.nio.file.Files;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
@@ -144,6 +145,7 @@ public class FTP extends Task implements FTPTaskConfig {
     private String siteCommand = null;
     private String initialSiteCommand = null;
     private boolean enableRemoteVerification = true;
+    private int dataTimeout = -1;
 
     protected static final String[] ACTION_STRS = { //NOSONAR
         "sending",
@@ -1695,6 +1697,19 @@ public class FTP extends Task implements FTPTaskConfig {
     }
 
     /**
+     * Sets the timeout on the data connection.
+     * Any negative value is discarded and leaves the default
+     *
+     * @param dataTimeout int
+     * @since Ant 1.10.6
+     */
+    public void setDataTimeout(int dataTimeout) {
+        if(dataTimeout >= 0) {
+            this.dataTimeout = dataTimeout;
+        }
+    }
+
+    /**
      * Checks to see that all required parameters are set.
      *
      * @throws BuildException if the configuration is not valid.
@@ -2443,6 +2458,11 @@ public class FTP extends Task implements FTPTaskConfig {
 
             ftp.setRemoteVerificationEnabled(enableRemoteVerification);
             ftp.connect(server, port);
+
+            if (dataTimeout >= 0) {
+                ftp.setDataTimeout(dataTimeout);
+                log("Setting data timeout to " + dataTimeout, Project.MSG_VERBOSE);
+            }
             if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
                 throw new BuildException("FTP connection failed: %s",
                     ftp.getReplyString());
@@ -2536,6 +2556,22 @@ public class FTP extends Task implements FTPTaskConfig {
             }
 
         } catch (IOException ex) {
+            String cause = ex.getCause().toString();
+            if(cause != null) {
+                if(cause.contains("java.net.SocketTimeoutException")) {
+                    // When a read timeout occurs, inform the server that it
+                    // should abort.
+                    // Note that the latest commons-net (3.6) still doesn't 
+                    // support sending urgent data, which is normally a
+                    // prerequisite for ABORT command.
+                    // As a consequence, it  might not be taken in account immediately
+                    try {
+                        ftp.abort();
+                    } catch(IOException ioe) {
+                        // ignore it
+                    }
+                }
+            }
             throw new BuildException("error during FTP transfer: " + ex, ex);
         } finally {
             if (ftp != null && ftp.isConnected()) {


[ant] 02/02: Add Ftp ant task timeout documentation also updated

Posted by jk...@apache.org.
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 1702b68043aa3d60562e6b54903ad377fc9ca591
Author: jkf <jm...@famkruithof.net>
AuthorDate: Fri Jul 12 16:05:46 2019 +0200

    Add Ftp ant task timeout documentation also updated
---
 manual/Tasks/ftp.html                                        | 8 +++++++-
 src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java | 5 +++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/manual/Tasks/ftp.html b/manual/Tasks/ftp.html
index b25f332..dad5ad9 100644
--- a/manual/Tasks/ftp.html
+++ b/manual/Tasks/ftp.html
@@ -190,7 +190,7 @@ connection.</p>
   <tr>
     <td>preservelastmodified</td>
     <td>Give the copied files the same last modified time as the original source files (applies to
-      getting files only).  (<strong>Note</strong>: Ignored on Java 1.1)</td>
+      getting files only).  (<strong>Note</strong>: Ignored on Java 1.1)</td>11
     <td>No; defaults to <q>false</q></td>
   </tr>
   <tr>
@@ -220,6 +220,12 @@ connection.</p>
     <td>No; default is <q>true</q></td>
   </tr>
   <tr>
+    <td>dataTimeout</td>
+    <td>Sets a timeout in milliseconds used when waiting for data on the data connection.
+      A value of 0 means an infinite timeout.<em>since Ant 1.10.7</em></td>
+    <td>No</td>
+  </tr>
+  <tr>
     <td colspan="3" class="left">
       <p><strong>The following attributes
       require <a href="https://commons.apache.org/net/download_net.cgi"
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 3be911a..ad16f41 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
@@ -1697,11 +1697,12 @@ public class FTP extends Task implements FTPTaskConfig {
     }
 
     /**
-     * Sets the timeout on the data connection.
+     * Sets the timeout on the data connection in milliseconds.
      * Any negative value is discarded and leaves the default
+     * A value of 0 means an infinite timeout
      *
      * @param dataTimeout int
-     * @since Ant 1.10.6
+     * @since Ant 1.10.7
      */
     public void setDataTimeout(int dataTimeout) {
         if(dataTimeout >= 0) {