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
This commit is contained in:
Luca Frosini 2015-11-19 15:07:12 +00:00
parent b316a78e8e
commit 440d1ae001
1 changed files with 8 additions and 6 deletions

View File

@ -79,12 +79,14 @@ public class AccountingPersistenceBackendMonitor implements Runnable {
} }
if(elaborationFile!=null){ if(elaborationFile!=null){
elaborateFile(elaborationFile); synchronized (elaborationFile) {
boolean deleted = elaborationFile.delete(); elaborateFile(elaborationFile);
if(!deleted){ boolean deleted = elaborationFile.delete();
logger.debug("Failed to delete file {}", elaborationFile.getAbsolutePath()); if(!deleted){
File elaborationFileNotDeleted = new File(elaborationFile.getAbsolutePath()+ELABORATION_FILE_NOT_DELETED_SUFFIX); logger.debug("Failed to delete file {}", elaborationFile.getAbsolutePath());
elaborationFile.renameTo(elaborationFileNotDeleted); File elaborationFileNotDeleted = new File(elaborationFile.getAbsolutePath()+ELABORATION_FILE_NOT_DELETED_SUFFIX);
elaborationFile.renameTo(elaborationFileNotDeleted);
}
} }
} }