aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-node/src
diff options
context:
space:
mode:
authorFiachra Corcoran <fiachra.corcoran@est.tech>2019-06-27 08:33:43 +0000
committerGerrit Code Review <gerrit@onap.org>2019-06-27 08:33:43 +0000
commit25d9192ad233ee72f93ca6002e8c80d03dc4efd1 (patch)
tree50a0b763278198dafe4b13401797e8ea3ffd173a /datarouter-node/src
parent56bef7eb388a5783ec27e7d641ea3e0f64e7abbd (diff)
parent6e72186116c333fae33bf103eb1f4fca692f17c9 (diff)
Merge "Adding more robust file deletion"
Diffstat (limited to 'datarouter-node/src')
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java
index bbd13912..91bd716b 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java
@@ -39,6 +39,7 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.ProtocolException;
import java.net.URL;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.UUID;
@@ -355,13 +356,27 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
* Remove meta and data files.
*/
void clean() {
- datafile.delete();
- metafile.delete();
+ deleteWithRetry(datafile);
+ deleteWithRetry(metafile);
eelfLogger.info(EelfMsgs.INVOKE, newInvocationId);
eelfLogger.info(EelfMsgs.EXIT);
hdrs = null;
}
+ private void deleteWithRetry(File file) {
+ int maxTries = 3;
+ int tryCount = 1;
+ while (tryCount <= maxTries) {
+ try {
+ Files.deleteIfExists(file.toPath());
+ break;
+ } catch (IOException e) {
+ eelfLogger.error("IOException : Failed to delete file :" + file.getName() + " on attempt " + tryCount, e);
+ }
+ tryCount++;
+ }
+ }
+
/**
* Get the resume time for a delivery task.
*/