From: Ryan Goulding Date: Fri, 13 Mar 2015 15:15:32 +0000 (-0400) Subject: Bug 2834: Fix Restconf POST to wait for completion X-Git-Tag: release/lithium~399 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=e219ac0369a2258e7b4b0cc37d4cf76f70ceb95b Bug 2834: Fix Restconf POST to wait for completion 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 --- diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java index 5f5b9bafe1..75c61d1c19 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java @@ -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; diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java index 730178ea32..1ac71bdec9 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java @@ -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.immediateCheckedFuture(null)); //FIXME : find who is set schemaContext // final String URI_1 = "/config";