Bug 5909 - PATCH does not report 409 on OptimisticLockFailedException 03/41703/13
authorIvan Hrasko <ihrasko@cisco.com>
Tue, 12 Jul 2016 10:51:30 +0000 (12:51 +0200)
committerIvan Hrasko <ihrasko@cisco.com>
Mon, 18 Jul 2016 13:56:37 +0000 (13:56 +0000)
- wait for transaction to be finished

Change-Id: I5440b866eada07ee6540c6b93d2e9174e62a37ce
Signed-off-by: Ivan Hrasko <ihrasko@cisco.com>
opendaylight/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java
opendaylight/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java

index 51cbde9e1467430932db10009570a8f869d9775d..7a1fb38ef98fae4fe8d35c50d19e0c02972af8cb 100644 (file)
@@ -129,7 +129,8 @@ public class BrokerFacade {
     }
 
     public PATCHStatusContext patchConfigurationDataWithinTransaction(final PATCHContext context,
-                                                                      final SchemaContext globalSchema) {
+                                                                      final SchemaContext globalSchema)
+            throws TransactionCommitFailedException {
         final DOMDataReadWriteTransaction patchTransaction = domDataBroker.newReadWriteTransaction();
         List<PATCHStatusEntity> editCollection = new ArrayList<>();
         List<RestconfError> editErrors;
@@ -214,7 +215,7 @@ public class BrokerFacade {
         //TODO: make sure possible global errors are filled up correctly and decide transaction submission based on that
         //globalErrors = new ArrayList<>();
         if (errorCounter == 0) {
-            final CheckedFuture<Void, TransactionCommitFailedException> submit = patchTransaction.submit();
+            patchTransaction.submit().checkedGet();
             return new PATCHStatusContext(context.getPatchId(), ImmutableList.copyOf(editCollection), true,
                     globalErrors);
         } else {
index fedcd6bb6ae4f7bae85e86a7a8c6474f13b42678..c292a382fc5bfa351759ff04ecd649c53f1e1fb2 100644 (file)
@@ -984,7 +984,12 @@ public class RestconfImpl implements RestconfService {
         if (context == null) {
             throw new RestconfDocumentedException("Input is required.", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE);
         }
-        return broker.patchConfigurationDataWithinTransaction(context, controllerContext.getGlobalSchema());
+        try {
+            return broker.patchConfigurationDataWithinTransaction(context, controllerContext.getGlobalSchema());
+        } catch (TransactionCommitFailedException e) {
+            LOG.debug("Patch transaction failed", e);
+            throw new RestconfDocumentedException(e.getMessage());
+        }
     }
 
     @Override
@@ -992,7 +997,12 @@ public class RestconfImpl implements RestconfService {
         if (context == null) {
             throw new RestconfDocumentedException("Input is required.", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE);
         }
-        return broker.patchConfigurationDataWithinTransaction(context, controllerContext.getGlobalSchema());
+        try {
+            return broker.patchConfigurationDataWithinTransaction(context, controllerContext.getGlobalSchema());
+        } catch (TransactionCommitFailedException e) {
+            LOG.debug("Patch transaction failed", e);
+            throw new RestconfDocumentedException(e.getMessage());
+        }
     }
 
     /**