Make naming consistent regarding synchronization
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / tasks / RicSynchronizationTask.java
index d759991..7c6e5ca 100644 (file)
@@ -82,9 +82,10 @@ public class RicSynchronizationTask {
             }
             ric.setState(RicState.SYNCHRONIZING);
         }
-        ric.getLock().lockBlocking(LockType.EXCLUSIVE); // Make sure no NBI updates are running
-        ric.getLock().unlock();
-        this.a1ClientFactory.createA1Client(ric)//
+
+        ric.getLock().lock(LockType.EXCLUSIVE) // Make sure no NBI updates are running
+            .flatMap(lock -> lock.unlock()) //
+            .flatMap(lock -> this.a1ClientFactory.createA1Client(ric)) //
             .flatMapMany(client -> startSynchronization(ric, client)) //
             .subscribe(x -> logger.debug("Synchronize: {}", x), //
                 throwable -> onSynchronizationError(ric, throwable), //
@@ -125,7 +126,7 @@ public class RicSynchronizationTask {
     @SuppressWarnings("squid:S2629")
     private void onSynchronizationError(Ric ric, Throwable t) {
         logger.warn("Synchronization failed for ric: {}, reason: {}", ric.name(), t.getMessage());
-        // If recovery fails, try to remove all instances
+        // If synchronization fails, try to remove all instances
         deleteAllPoliciesInRepository(ric);
 
         Flux<PolicyType> recoverTypes = this.a1ClientFactory.createA1Client(ric) //