Bug 2834: Fix Restconf POST to wait for completion 92/16492/8
authorRyan Goulding <ryandgoulding@gmail.com>
Fri, 13 Mar 2015 15:15:32 +0000 (11:15 -0400)
committerRyan Goulding <ryandgoulding@gmail.com>
Fri, 13 Mar 2015 20:05:05 +0000 (16:05 -0400)
This changeset introduces a blocking mechanism for Restconf POST to ensure that
the transaction completes before a response is returned, as is consistent with
Restconf PUT behavior.  checkedGet() is utilized to ensure write transaction
completion.

Change-Id: I74f68b883f6037ec62644a468d3cbb9370d8d25f
Signed-off-by: Ryan Goulding <ryandgoulding@gmail.com>
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java

index 5f5b9ba..75c61d1 100644 (file)
@@ -1212,10 +1212,9 @@ public class RestconfImpl implements RestconfService {
         final YangInstanceIdentifier resultII;
         try {
             if (mountPoint != null) {
-                broker.commitConfigurationDataPost(mountPoint, normalizedII, payload.getData());
-
+                broker.commitConfigurationDataPost(mountPoint, normalizedII, payload.getData()).checkedGet();
             } else {
-                broker.commitConfigurationDataPost(normalizedII, payload.getData());
+                broker.commitConfigurationDataPost(normalizedII, payload.getData()).checkedGet();
             }
         } catch(final RestconfDocumentedException e) {
             throw e;
index 730178e..1ac71bd 100644 (file)
@@ -19,6 +19,7 @@ import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUt
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
@@ -40,6 +41,7 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.controller.sal.rest.api.Draft02;
@@ -268,8 +270,8 @@ public class RestPostOperationTest extends JerseyTest {
     public void createConfigurationDataNullTest() throws UnsupportedEncodingException {
         initMocking();
 
-        when(brokerFacade.commitConfigurationDataPost(any(YangInstanceIdentifier.class), any(NormalizedNode.class)))
-                .thenReturn(null);
+        when(brokerFacade.commitConfigurationDataPost(any(YangInstanceIdentifier.class),any(NormalizedNode.class)))
+                .thenReturn(Futures.<Void, TransactionCommitFailedException>immediateCheckedFuture(null));
 
         //FIXME : find who is set schemaContext
 //        final String URI_1 = "/config";

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.