ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1211004 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW contributors.xml src/main/org/apache/tools/ant/taskdefs/Retry.java
Date Tue, 06 Dec 2011 16:33:19 GMT
Author: bodewig
Date: Tue Dec  6 16:33:19 2011
New Revision: 1211004

URL: http://svn.apache.org/viewvc?rev=1211004&view=rev
Log:
Allow retry task to sleep between retry attempts.  Submitted by Arjan Veenstra.  PR 52076

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=1211004&r1=1211003&r2=1211004&view=diff
==============================================================================
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Tue Dec  6 16:33:19 2011
@@ -25,6 +25,7 @@ Anthony Wat
 Antoine Baudoux
 Antoine Levy-Lambert
 Anton Mazkovoi
+Arjan Veenstra
 Arnaud Vandyck
 Arnout J. Kuiper
 Aslak Hellesôy

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1211004&r1=1211003&r2=1211004&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Dec  6 16:33:19 2011
@@ -163,6 +163,10 @@ Other changes:
  * URLResources#isExists has become less noisy.
    Bugzilla Report 51802.
 
+ * The <retry> task has a new optional attribute retryDelay that can
+   be used to make the task sleep between retry attempts.
+   Bugzilla Report 52076.
+
 Changes from Ant 1.8.1 TO Ant 1.8.2
 ===================================
 

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=1211004&r1=1211003&r2=1211004&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Tue Dec  6 16:33:19 2011
@@ -124,6 +124,10 @@
     <last>Mazkovoi</last>
   </name>
   <name>
+    <first>Arjan</first>
+    <last>Veenstra</last>
+  </name>
+  <name>
     <first>Arnaud</first>
     <last>Vandyck</last>
   </name>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java?rev=1211004&r1=1211003&r2=1211004&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java Tue Dec  6 16:33:19 2011
@@ -40,6 +40,11 @@ public class Retry extends Task implemen
     private int retryCount = 1;
 
     /**
+     * The time to wait between retries in milliseconds, default to 0.
+     */
+    private int retryDelay = 0;
+
+    /**
      * set the task
      * @param t the task to retry.
      */
@@ -61,6 +66,18 @@ public class Retry extends Task implemen
     }
 
     /**
+     * set the delay between retries (in miliseconds)
+     * @param n the time between retries.
+     * @since Ant 1.8.3
+     */
+    public void setRetryDelay(int retryDelay) {
+        if (retryDelay < 0) {
+            throw new BuildException("delay must be a non-negative number");
+        }
+        this.retryDelay = retryDelay;
+    }
+
+    /**
      * perform the work
      * @throws BuildException if there is an error.
      */
@@ -81,8 +98,21 @@ public class Retry extends Task implemen
                     exceptionMessage.append(errorMessages);
                     throw new BuildException(exceptionMessage.toString(), getLocation());
                 }
-                log("Attempt [" + i + "]: error occurred; retrying...", e, Project.MSG_INFO);
+                String msg;
+                if (retryDelay > 0) {
+                    msg = "Attempt [" + i + "]: error occurred; retrying after " + retryDelay
+ " ms...";
+                } else {
+                    msg = "Attempt [" + i + "]: error occurred; retrying...";
+                }
+                log(msg, e, Project.MSG_INFO);
                 errorMessages.append(StringUtils.LINE_SEP);
+                if (retryDelay > 0) {
+                    try {
+                        Thread.sleep(retryDelay);
+                    } catch (InterruptedException ie) {
+                        // Ignore Exception
+                    }
+                }
             }
         }
     }



Mime
View raw message