Clear out tx reference immediately after submit. 83/47783/2
authorTomas Cere <tcere@cisco.com>
Mon, 31 Oct 2016 15:23:00 +0000 (16:23 +0100)
committerTomas Cere <tcere@cisco.com>
Mon, 31 Oct 2016 15:30:19 +0000 (16:30 +0100)
When sumbmitting multiple transactions after each other
you could get into a state in which a transaction was submitted
and the reference wasn't cleared out in the callback resulting in
attempts to use an already finished transaction.

Change-Id: Iebf6ed10760c106e45c51665c63f45debe7e7063
Signed-off-by: Tomas Cere <tcere@cisco.com>
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/tx/NetconfMasterDOMTransaction.java

index 33680f2dfc2701212e17ae068b54a82f04528d74..356b3bf705d7decb20887922211cf679ae059145 100644 (file)
@@ -152,18 +152,18 @@ public class NetconfMasterDOMTransaction implements NetconfDOMTransaction {
         LOG.trace("{}: Submit[{}} via NETCONF", id, writeTx.getIdentifier());
 
         final CheckedFuture<Void, TransactionCommitFailedException> submitFuture = writeTx.submit();
+        writeTx = null;
+
         final DefaultPromise<Void> promise = new DefaultPromise<>();
         Futures.addCallback(submitFuture, new FutureCallback<Void>() {
             @Override
             public void onSuccess(final Void result) {
                 promise.success(result);
-                writeTx = null;
             }
 
             @Override
             public void onFailure(@Nonnull final Throwable throwable) {
                 promise.failure(throwable);
-                writeTx = null;
             }
         });
         return promise.future();