Cancel transaction on failure in restconf 14/13714/3
authorMaros Marsalek <mmarsale@cisco.com>
Wed, 17 Dec 2014 13:38:35 +0000 (14:38 +0100)
committerMaros Marsalek <mmarsale@cisco.com>
Mon, 12 Jan 2015 11:52:36 +0000 (11:52 +0000)
This allows for proper resource cleanup for e.g. remote netconf transaction

Change-Id: Ib072ca3497a363d1a813c2161f25d10c536c3614
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java

index 95fb9a4826d2b6c5115c31d6dfff066b9a0b4af5..7cd20ee733dac07483bb378429ff6a6a6f64cc75 100644 (file)
@@ -205,6 +205,7 @@ public class BrokerFacade {
             if (optionalDatastoreData.isPresent() && payload.equals(optionalDatastoreData.get())) {
                 String errMsg = "Post Configuration via Restconf was not executed because data already exists";
                 LOG.trace(errMsg + ":{}", path);
+                rWTransaction.cancel();
                 throw new RestconfDocumentedException("Data already exists for path: " + path, ErrorType.PROTOCOL,
                         ErrorTag.DATA_EXISTS);
             }
@@ -250,6 +251,7 @@ public class BrokerFacade {
             try {
                 currentOp = currentOp.getChild(currentArg);
             } catch (DataNormalizationException e) {
+                rwTx.cancel();
                 throw new IllegalArgumentException(
                         String.format("Invalid child encountered in path %s", normalizedPath), e);
             }
@@ -264,6 +266,7 @@ public class BrokerFacade {
                 exists = future.checkedGet();
             } catch (ReadFailedException e) {
                 LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e);
+                rwTx.cancel();
                 throw new IllegalStateException("Failed to read pre-existing data", e);
             }