Bug 7011 - Race condition in statistics collection related transaction chain handling
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / device / TransactionChainManager.java
index 0912b37ec75a4d2fb29be16bf394800b6fa51ced..da4bdae04e427d42efd4ab7eebbf44e3b0b27e7d 100644 (file)
@@ -79,8 +79,9 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
 
     @GuardedBy("txLock")
     private void createTxChain() {
-        Optional.ofNullable(txChainFactory).ifPresent(TransactionChain::close);
+        BindingTransactionChain txChainFactoryTemp = txChainFactory;
         txChainFactory = dataBroker.createTransactionChain(TransactionChainManager.this);
+        Optional.ofNullable(txChainFactoryTemp).ifPresent(TransactionChain::close);
     }
 
     public void setLifecycleService(final LifecycleService lifecycleService) {
@@ -234,7 +235,7 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
     public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
                                          final AsyncTransaction<?, ?> transaction, final Throwable cause) {
         if (transactionChainManagerStatus.equals(TransactionChainManagerStatus.WORKING)) {
-            LOG.warn("txChain failed -> recreating due to {}", cause);
+            LOG.warn("Transaction chain failed, recreating chain due to ", cause);
             recreateTxChain();
         }
     }