BUG 3066 : Optimistic lock failed, on NetconfStateUpdate 29/19229/1
authorTomas Cere <tcere@cisco.com>
Tue, 28 Apr 2015 09:09:50 +0000 (11:09 +0200)
committerTomas Cere <tcere@cisco.com>
Tue, 28 Apr 2015 15:15:18 +0000 (15:15 +0000)
Fixed race condition between commit of NetconfState and
opening of a new transaction in NetconfMonitoring state update.

Change-Id: I2f56a0e432e630e56a35409c56e4198a3e278594
Signed-off-by: Tomas Cere <tcere@cisco.com>
opendaylight/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MonitoringToMdsalWriter.java

index 50958e423f4a14e5af67435f4b3d0f745a97ef87..3dbcc53822e7919fa184541c47d224c2440bc8fc 100644 (file)
@@ -61,19 +61,12 @@ final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMonitoringS
         tx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(NetconfState.class), state);
         // FIXME first attempt (right after we register to binding broker) always fails
         // Is it due to the fact that we are writing from the onSessionInitiated callback ?
-        final CheckedFuture<Void, TransactionCommitFailedException> submit = tx.submit();
-
-        Futures.addCallback(submit, new FutureCallback<Void>() {
-            @Override
-            public void onSuccess(final Void aVoid) {
-                LOG.debug("Netconf state updated successfully");
-            }
-
-            @Override
-            public void onFailure(final Throwable throwable) {
-                LOG.warn("Unable to update netconf state", throwable);
-            }
-        });
+        try {
+            tx.submit().checkedGet();
+            LOG.debug("Netconf state updated successfully");
+        } catch (TransactionCommitFailedException e) {
+            LOG.warn("Unable to update netconf state", e);
+        }
     }
 
     @Override