From df5cd0c4e6d79e51ae1eb8697ee2df76791bc9b2 Mon Sep 17 00:00:00 2001 From: Chetan Mehrotra Date: Tue, 24 Apr 2018 11:16:36 +0530 Subject: [PATCH] Increase response chunk size limit to 2 MB Set the default maxChunkSize for HttpObjectAggregationConfigurator to 2 MB as CosmosDB allows documents of size upto 2 MB Fixes #33 --- .../rx/internal/RxDocumentClientImpl.java | 3 ++- .../azure/cosmosdb/rx/DocumentCrudTest.java | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/sdk/src/main/java/com/microsoft/azure/cosmosdb/rx/internal/RxDocumentClientImpl.java b/sdk/src/main/java/com/microsoft/azure/cosmosdb/rx/internal/RxDocumentClientImpl.java index 9e90b9838230a..aa737495be5b4 100644 --- a/sdk/src/main/java/com/microsoft/azure/cosmosdb/rx/internal/RxDocumentClientImpl.java +++ b/sdk/src/main/java/com/microsoft/azure/cosmosdb/rx/internal/RxDocumentClientImpl.java @@ -27,6 +27,7 @@ import static com.microsoft.azure.cosmosdb.BridgeInternal.toFeedResponsePage; import static com.microsoft.azure.cosmosdb.BridgeInternal.toResourceResponse; import static com.microsoft.azure.cosmosdb.BridgeInternal.toStoredProcedureResponse; +import static org.apache.commons.io.FileUtils.ONE_MB; import java.io.IOException; import java.io.InputStream; @@ -271,7 +272,7 @@ private PipelineConfigurator createClientPipelineConfigurator() { MAX_REQUEST_HEADER_SIZE, HttpClientPipelineConfigurator.MAX_CHUNK_SIZE_DEFAULT, true), - new HttpObjectAggregationConfigurator<>()); + new HttpObjectAggregationConfigurator((int)(ONE_MB * 2))); return clientPipelineConfigurator; } diff --git a/sdk/src/test/java/com/microsoft/azure/cosmosdb/rx/DocumentCrudTest.java b/sdk/src/test/java/com/microsoft/azure/cosmosdb/rx/DocumentCrudTest.java index 813b9abdcd51c..593a6fbbb1d4c 100644 --- a/sdk/src/test/java/com/microsoft/azure/cosmosdb/rx/DocumentCrudTest.java +++ b/sdk/src/test/java/com/microsoft/azure/cosmosdb/rx/DocumentCrudTest.java @@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.apache.commons.lang3.StringUtils; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Factory; @@ -43,6 +44,8 @@ import rx.Observable; +import static org.apache.commons.io.FileUtils.ONE_MB; + public class DocumentCrudTest extends TestSuiteBase { public final static String DATABASE_ID = getDatabaseId(DocumentCrudTest.class); @@ -72,6 +75,24 @@ public void createDocument() throws Exception { validateSuccess(createObservable, validator); } + @Test(groups = { "simple" }, timeOut = TIMEOUT) + public void createLargeDocument() throws Exception { + Document docDefinition = getDocumentDefinition(); + + //Keep size as ~ 1.5MB to account for size of other props + int size = (int) (ONE_MB * 1.5); + docDefinition.set("largeString", StringUtils.repeat("x", size)); + + Observable> createObservable = client + .createDocument(getCollectionLink(), docDefinition, null, false); + + ResourceResponseValidator validator = new ResourceResponseValidator.Builder() + .withId(docDefinition.getId()) + .build(); + + validateSuccess(createObservable, validator); + } + @Test(groups = { "simple" }, timeOut = TIMEOUT) public void createDocument_AlreadyExists() throws Exception { Document docDefinition = getDocumentDefinition();