From e7d89ededf59be3e04364eb9aff490bcb31ba148 Mon Sep 17 00:00:00 2001 From: Lucio Lelii Date: Tue, 17 Nov 2015 17:22:22 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@120296 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../AccountingPersistenceBackendFactory.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceBackendFactory.java b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceBackendFactory.java index 785202b..304a85b 100644 --- a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceBackendFactory.java +++ b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceBackendFactory.java @@ -119,13 +119,12 @@ public abstract class AccountingPersistenceBackendFactory { logger.debug("The {} for scope {} is {}. Is time to rediscover if there is another possibility.", AccountingPersistenceBackend.class.getSimpleName(), scope, actual.getClass().getSimpleName()); - lock.lock(); try { - logger.trace("Renewing Last check Timestamp. The next one will be {}", now); - fallbackLastCheck.put(scope, now); - lastCheckTimestamp = fallbackLastCheck.get(scope); + AccountingPersistenceBackend discoveredPersistenceBackend = discoverAccountingPersistenceBackend(scope); + + lock.lock(); if(discoveredPersistenceBackend!=null){ // Passing the aggregator to the new AccountingPersistenceBackend // so that the buffered records will be persisted with the new method @@ -143,6 +142,10 @@ public abstract class AccountingPersistenceBackendFactory { } lock.unlock(); return discoveredPersistenceBackend; + }else{ + logger.trace("Renewing Last check Timestamp. The next one will be {}", now); + fallbackLastCheck.put(scope, now); + lastCheckTimestamp = fallbackLastCheck.get(scope); } }finally { lock.unlock(); @@ -159,7 +162,7 @@ public abstract class AccountingPersistenceBackendFactory { return actual; } - protected static synchronized AccountingPersistenceBackend getPersistenceBackend() { + protected static AccountingPersistenceBackend getPersistenceBackend() { String scope = ScopeProvider.instance.get(); if(scope==null){