From 440d1ae001e416e784307c063cfe913059efc788 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 19 Nov 2015 15:07:12 +0000 Subject: [PATCH] Fixing code to support retry git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@120323 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../AccountingPersistenceBackendMonitor.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceBackendMonitor.java b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceBackendMonitor.java index 0563f62..699a21e 100644 --- a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceBackendMonitor.java +++ b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceBackendMonitor.java @@ -79,12 +79,14 @@ public class AccountingPersistenceBackendMonitor implements Runnable { } if(elaborationFile!=null){ - elaborateFile(elaborationFile); - boolean deleted = elaborationFile.delete(); - if(!deleted){ - logger.debug("Failed to delete file {}", elaborationFile.getAbsolutePath()); - File elaborationFileNotDeleted = new File(elaborationFile.getAbsolutePath()+ELABORATION_FILE_NOT_DELETED_SUFFIX); - elaborationFile.renameTo(elaborationFileNotDeleted); + synchronized (elaborationFile) { + elaborateFile(elaborationFile); + boolean deleted = elaborationFile.delete(); + if(!deleted){ + logger.debug("Failed to delete file {}", elaborationFile.getAbsolutePath()); + File elaborationFileNotDeleted = new File(elaborationFile.getAbsolutePath()+ELABORATION_FILE_NOT_DELETED_SUFFIX); + elaborationFile.renameTo(elaborationFileNotDeleted); + } } }