diff options
Diffstat (limited to 'vnfapi/provider/src/main')
-rw-r--r-- | vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java index e8a9e716..30f85859 100644 --- a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java +++ b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java @@ -771,30 +771,33 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL InstanceIdentifier.<Vnfs>builder(Vnfs.class).child(VnfList.class, entry.getKey()); InstanceIdentifier<VnfList> path = vnfListIdBuilder.build(); - int tries = 2; - while (true) { + int optimisticLockTries = 2; + boolean tryAgain =true; + while (tryAgain) { + tryAgain = false; try { WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); tx.delete(storeType, path); tx.submit().checkedGet(); log.debug("DataStore delete succeeded"); - break; } catch (final TransactionCommitFailedException e) { if (e instanceof OptimisticLockFailedException) { - if (--tries <= 0) { + if (--optimisticLockTries <= 0) { log.debug("Got OptimisticLockFailedException on last try - failing "); throw new IllegalStateException(e); } log.debug("Got OptimisticLockFailedException - trying again "); + tryAgain = true; + continue; } - else { - if (e.getCause() instanceof ModifiedNodeDoesNotExistException) { - log.debug("Ignoring MpdifiedNodeDoesNotExistException"); - } else { - log.debug("Delete DataStore failed"); - throw new IllegalStateException(e); - } + + if (e.getCause() instanceof ModifiedNodeDoesNotExistException) { + log.debug("Ignoring MpdifiedNodeDoesNotExistException"); + break; } + + log.debug("Delete DataStore failed"); + throw new IllegalStateException(e); } } } |