bug 5096 Clean up transaction in case of failure 74/34474/1
authorAndrej Mak <andmak@cisco.com>
Thu, 4 Feb 2016 15:03:54 +0000 (16:03 +0100)
committerTomas Cere <tcere@cisco.com>
Thu, 11 Feb 2016 16:06:58 +0000 (16:06 +0000)
In case of transaction fail, clean up failed transaction,
so it is posible to start new. Add more detailed error message.

Change-Id: I2ea39cc37994175974108cbf8e1afdbd9a3a2282
Signed-off-by: Andrej Mak <andmak@cisco.com>
opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/TransactionProvider.java

index 1eacbf364b739a7796a31204baa8ab1fd059f3ac..0bcd7370fc58f4f9dde85a9250b599004826fa58 100644 (file)
@@ -83,11 +83,14 @@ public class TransactionProvider implements AutoCloseable{
             future.checkedGet();
         } catch (TransactionCommitFailedException e) {
             LOG.debug("Transaction {} failed on", candidateTransaction, e);
-            throw new DocumentedException("Transaction commit failed on " + e.getMessage() + " " + netconfSessionIdForReporting,
+            final String cause = e.getCause() != null ? (" Cause: " + e.getCause().getMessage()) : "";
+            throw new DocumentedException("Transaction commit failed on " + e.getMessage() + " " + netconfSessionIdForReporting +
+                    cause,
                     ErrorType.application, ErrorTag.operation_failed, ErrorSeverity.error);
+        } finally {
+            allOpenReadWriteTransactions.remove(candidateTransaction);
+            candidateTransaction = null;
         }
-        allOpenReadWriteTransactions.remove(candidateTransaction);
-        candidateTransaction = null;
 
         return true;
     }