Bug 4455 - Inconsistent COMMIT operation handling when no transactions are present 95/34895/2
authorTomas Cere <tcere@cisco.com>
Thu, 18 Feb 2016 11:40:52 +0000 (12:40 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 25 Feb 2016 10:00:47 +0000 (10:00 +0000)
Return positive response for commit operation in netconf mdsal
northbound even if no candidate transaction is open for session.

port of:
https://git.opendaylight.org/gerrit/#/c/32938/

Change-Id: I892679d2d4ba50ecb887aefccac5b7d4ef6639f8
Signed-off-by: Tomas Cere <tcere@cisco.com>
opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/TransactionProvider.java
opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/Commit.java
opendaylight/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/controller/netconf/mdsal/connector/ops/NetconfMDSalMappingTest.java

index 86e65abbbe6f232396ba786de230473c57977b63..602d5720111fbde82a9082c42970f1a2d61ae38a 100644 (file)
@@ -73,8 +73,9 @@ public class TransactionProvider implements AutoCloseable{
 
     public synchronized boolean commitTransaction() throws NetconfDocumentedException {
         if (!getCandidateTransaction().isPresent()) {
-            throw new NetconfDocumentedException(NO_TRANSACTION_FOUND_FOR_SESSION + netconfSessionIdForReporting,
-                    ErrorType.application, ErrorTag.operation_failed, ErrorSeverity.error);
+            //making empty commit without prior opened transaction, just return true
+            LOG.debug("Making commit without open candidate transaction for session {}", netconfSessionIdForReporting);
+            return true;
         }
 
         CheckedFuture<Void, TransactionCommitFailedException> future = candidateTransaction.submit();
index 47e8f80585cdfc9411c15856722149906610d145..a8800c845136a57afdb2e5071fb700b1619adb51 100644 (file)
@@ -37,7 +37,7 @@ public class Commit extends AbstractSingletonNetconfOperation {
     protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) throws NetconfDocumentedException {
 
         boolean commitStatus = transactionProvider.commitTransaction();
-        LOG.trace("Transaction commited succesfuly {}", commitStatus);
+        LOG.trace("Commit completed successfully {}", commitStatus);
 
         return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
     }
index 587375db7a46081f7ea20028b9b140b699f2c86c..62ec421e7c7f745ff0521584bc09e902453b1371 100644 (file)
@@ -162,6 +162,12 @@ public class NetconfMDSalMappingTest {
 
     }
 
+    @Test
+    public void testCommitWithoutOpenTransaction() throws Exception {
+        verifyResponse(commit(), RPC_REPLY_OK);
+        assertEmptyDatastore(getConfigCandidate());
+    }
+
     @Test
     public void testCandidateTransaction() throws Exception {