Browse Source

Allow retry task to sleep between retry attempts. Submitted by Arjan Veenstra. PR 52076

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1211004 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 13 years ago
parent
commit
291e7b0217
4 changed files with 40 additions and 1 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +4
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +31
    -1
      src/main/org/apache/tools/ant/taskdefs/Retry.java

+ 1
- 0
CONTRIBUTORS View File

@@ -25,6 +25,7 @@ Anthony Wat
Antoine Baudoux
Antoine Levy-Lambert
Anton Mazkovoi
Arjan Veenstra
Arnaud Vandyck
Arnout J. Kuiper
Aslak Hellesôy


+ 4
- 0
WHATSNEW View File

@@ -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
===================================



+ 4
- 0
contributors.xml View File

@@ -123,6 +123,10 @@
<first>Anton</first>
<last>Mazkovoi</last>
</name>
<name>
<first>Arjan</first>
<last>Veenstra</last>
</name>
<name>
<first>Arnaud</first>
<last>Vandyck</last>


+ 31
- 1
src/main/org/apache/tools/ant/taskdefs/Retry.java View File

@@ -39,6 +39,11 @@ public class Retry extends Task implements TaskContainer {
*/
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.
@@ -60,6 +65,18 @@ public class Retry extends Task implements TaskContainer {
retryCount = n;
}

/**
* 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 implements TaskContainer {
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
}
}
}
}
}

Loading…
Cancel
Save