diff --git a/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/examples/BasicDemo.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/examples/BasicDemo.java index 8075d2f299f7..0c7bfe64ac6b 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/examples/BasicDemo.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/examples/BasicDemo.java @@ -129,7 +129,7 @@ private void queryWithContinuationToken() { log("+ Query with paging using continuation token"); String query = "SELECT * from root r "; FeedOptions options = new FeedOptions(); - options.setPopulateQueryMetrics(true); + options.setQueryMetricsEnabled(true); String continuation = null; do { CosmosPagedFlux queryFlux = container.queryItems(query, options, TestObject.class); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncClient.java index 92c076a4acb9..a0b89893e4d7 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncClient.java @@ -194,7 +194,7 @@ boolean isContentResponseOnWriteEnabled() { * @return a {@link Mono} containing the cosmos database response with the created or existing database or * an error. */ - public Mono createDatabaseIfNotExists(CosmosDatabaseProperties databaseSettings) { + Mono createDatabaseIfNotExists(CosmosDatabaseProperties databaseSettings) { return createDatabaseIfNotExistsInternal(getDatabase(databaseSettings.getId())); } @@ -229,6 +229,9 @@ private Mono createDatabaseIfNotExistsInternal(Cosm /** * Create a Database if it does not already exist on the service. *

+ * The throughputProperties will only be used if the specified database + * does not exist and therefor a new database will be created with throughputProperties. + *

* The {@link Mono} upon successful completion will contain a single cosmos database response with the * created or existing database. * diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncUser.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncUser.java index 3ab7ef8a39e4..afeff369853a 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncUser.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncUser.java @@ -62,7 +62,7 @@ public Mono read() { } /** - * REPLACE a cosmos user + * Replace a cosmos user * * @param userSettings the user properties to use * @return a {@link Mono} containing the single resource response with the replaced user or an error. @@ -226,7 +226,7 @@ String getLink() { * * @return the (@link CosmosAsyncDatabase) */ - public CosmosAsyncDatabase getDatabase() { + CosmosAsyncDatabase getDatabase() { return database; } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClient.java index fd98ccdfb7ea..efd9a3e2e7af 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClient.java @@ -22,7 +22,7 @@ /** * Provides a client-side logical representation of the Azure Cosmos DB service. - * SyncClient is used to perform operations in a synchronous way + * Calls to CosmosClient API's are blocked for completion. */ @ServiceClient(builder = CosmosClientBuilder.class) public final class CosmosClient implements Closeable { @@ -38,12 +38,15 @@ public final class CosmosClient implements Closeable { * @param databaseProperties {@link CosmosDatabaseProperties} the database properties. * @return the {@link CosmosDatabaseResponse} with the created database. */ - public CosmosDatabaseResponse createDatabaseIfNotExists(CosmosDatabaseProperties databaseProperties) { + CosmosDatabaseResponse createDatabaseIfNotExists(CosmosDatabaseProperties databaseProperties) { return mapDatabaseResponseAndBlock(asyncClientWrapper.createDatabaseIfNotExists(databaseProperties)); } /** * Create a Database if it does not already exist on the service. + *

+ * The throughputProperties will only be used if the specified database + * does not exist and therefor a new database will be created with throughputProperties. * * @param id the id of the database. * @param throughputProperties the throughputProperties. diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClientBuilder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClientBuilder.java index 0ce0344739bb..2492a7c63057 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClientBuilder.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClientBuilder.java @@ -16,12 +16,13 @@ /** * Helper class to build CosmosAsyncClient {@link CosmosAsyncClient} and CosmosClient {@link CosmosClient} * instances as logical representation of the Azure Cosmos database service. - * + *

* When building client, endpoint() and key() are mandatory APIs, without these the initialization will fail. - * + *

* Though consistencyLevel is not mandatory, but we strongly suggest to pay attention to this API when building client. - * By default, database account level consistency level is used if none is provided. - * + * By default, account consistency level is used if none is provided. + *

+ * By default, direct connection mode is used if none specified. *

  *     Building Cosmos Async Client minimal APIs (without any customized configurations)
  * {@code
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosContainer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosContainer.java
index 0f60e18334f8..92100dd2d124 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosContainer.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosContainer.java
@@ -197,10 +197,8 @@ public  CosmosItemResponse upsertItem(T item) {
      * @param options the options.
      * @return the Cosmos sync item response.
      */
-    @SuppressWarnings("unchecked")
-    // Note: @kushagraThapar and @moderakh to ensure this casting is valid
-    public  CosmosItemResponse upsertItem(Object item, CosmosItemRequestOptions options) {
-        return (CosmosItemResponse) this.mapItemResponseAndBlock(this.asyncContainer.upsertItem(item, options));
+    public  CosmosItemResponse upsertItem(T item, CosmosItemRequestOptions options) {
+        return this.mapItemResponseAndBlock(this.asyncContainer.upsertItem(item, options));
     }
 
     /**
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ChangeFeedOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ChangeFeedOptions.java
index b28435107132..dfc0adad7df6 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ChangeFeedOptions.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ChangeFeedOptions.java
@@ -19,14 +19,14 @@ public final class ChangeFeedOptions {
     private Integer maxItemCount;
     private String requestContinuation;
     private PartitionKey partitionkey;
-    private final boolean populateQueryMetrics;
+    private final boolean queryMetricsEnabled;
     private Map properties;
 
     /**
      * Instantiates a new Change feed options.
      */
     public ChangeFeedOptions() {
-        this.populateQueryMetrics = false;
+        this.queryMetricsEnabled = false;
     }
 
     /**
@@ -41,7 +41,7 @@ public ChangeFeedOptions(ChangeFeedOptions options) {
         this.maxItemCount = options.maxItemCount;
         this.requestContinuation = options.requestContinuation;
         this.partitionkey = options.partitionkey;
-        this.populateQueryMetrics = options.populateQueryMetrics;
+        this.queryMetricsEnabled = options.queryMetricsEnabled;
     }
 
     /**
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Conflict.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Conflict.java
index 416cbf723bab..52627f3934b5 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Conflict.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Conflict.java
@@ -42,7 +42,7 @@ public String getOperationKind() {
      *
      * @return the resource type.
      */
-    public String getResouceType() {
+    public String getResourceType() {
         return super.getString(Constants.Properties.RESOURCE_TYPE);
     }
 
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java
index 39e73e3868f4..9beaf90a7bb6 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java
@@ -30,7 +30,7 @@ public class RequestOptions {
     private PartitionKey partitionkey;
     private String partitionKeyRangeId;
     private boolean scriptLoggingEnabled;
-    private boolean populateQuotaInfo;
+    private boolean quotaInfoEnabled;
     private Map properties;
     private ThroughputProperties throughputProperties;
 
@@ -279,25 +279,25 @@ public void setScriptLoggingEnabled(boolean scriptLoggingEnabled) {
     }
 
     /**
-     * Gets the PopulateQuotaInfo setting for document collection read requests in the Azure Cosmos DB database service.
-     * PopulateQuotaInfo is used to enable/disable getting document collection quota related stats for document
+     * Gets the quotaInfoEnabled setting for document collection read requests in the Azure Cosmos DB database service.
+     * quotaInfoEnabled is used to enable/disable getting document collection quota related stats for document
      * collection read requests.
      *
-     * @return true if PopulateQuotaInfo is enabled
+     * @return true if quotaInfoEnabled is enabled
      */
-    public boolean isPopulateQuotaInfo() {
-        return populateQuotaInfo;
+    public boolean isQuotaInfoEnabled() {
+        return quotaInfoEnabled;
     }
 
     /**
-     * Sets the PopulateQuotaInfo setting for document collection read requests in the Azure Cosmos DB database service.
-     * PopulateQuotaInfo is used to enable/disable getting document collection quota related stats for document
+     * Sets the quotaInfoEnabled setting for document collection read requests in the Azure Cosmos DB database service.
+     * quotaInfoEnabled is used to enable/disable getting document collection quota related stats for document
      * collection read requests.
      *
-     * @param populateQuotaInfo a boolean value indicating whether PopulateQuotaInfo is enabled or not
+     * @param quotaInfoEnabled a boolean value indicating whether quotaInfoEnabled is enabled or not
      */
-    public void setPopulateQuotaInfo(boolean populateQuotaInfo) {
-        this.populateQuotaInfo = populateQuotaInfo;
+    public void setQuotaInfoEnabled(boolean quotaInfoEnabled) {
+        this.quotaInfoEnabled = quotaInfoEnabled;
     }
 
     /**
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java
index 593b720ba0a1..793704e345cb 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java
@@ -958,7 +958,7 @@ private Map getRequestHeaders(RequestOptions options, ResourceTy
             }
         }
 
-        if (options.isPopulateQuotaInfo()) {
+        if (options.isQuotaInfoEnabled()) {
             headers.put(HttpConstants.HttpHeaders.POPULATE_QUOTA_INFO, String.valueOf(true));
         }
 
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/SessionTokenHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/SessionTokenHelper.java
index 26c394d48e0d..8719902b63ac 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/SessionTokenHelper.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/SessionTokenHelper.java
@@ -65,7 +65,7 @@ private static ISessionToken getLocalSessionToken(
             String globalSessionToken,
             String partitionKeyRangeId) {
 
-        if (partitionKeyRangeId == null || partitionKeyRangeId.isEmpty()) {
+        if (partitionKeyRangeId == null) {
             // AddressCache/address resolution didn't produce partition key range id.
             // In this case it is a bug.
             throw new IllegalStateException("Partition key range Id is absent in the context.");
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Utils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Utils.java
index 22fa865c9868..01bbee1e7a6c 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Utils.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Utils.java
@@ -30,6 +30,7 @@
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Base64;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -290,6 +291,13 @@ public static String getCollectionName(String resourceFullName) {
         return resourceFullName;
     }
 
+    public static  int getCollectionSize(Collection collection) {
+        if (collection == null) {
+            return 0;
+        }
+        return collection.size();
+    }
+
     public static Boolean isCollectionPartitioned(DocumentCollection collection) {
         if (collection == null) {
             throw new IllegalArgumentException("collection");
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/AddressResolver.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/AddressResolver.java
index c3029c1d6a23..53748ee926d3 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/AddressResolver.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/AddressResolver.java
@@ -651,7 +651,7 @@ private PartitionKeyRange tryResolveServerPartitionByPartitionKey(
             throw new InternalServerErrorException(String.format("partition key is null"));
         }
 
-        if (partitionKey.equals(PartitionKeyInternal.Empty) || partitionKey.getComponents().size() == collection.getPartitionKey().getPaths().size()) {
+        if (partitionKey.equals(PartitionKeyInternal.Empty) || Utils.getCollectionSize(partitionKey.getComponents()) == collection.getPartitionKey().getPaths().size()) {
             // Although we can compute effective partition getKey here, in general case this GATEWAY can have outdated
             // partition getKey definition cached - like if collection with same getName but with RANGE partitioning is created.
             // In this case server will not pass x-ms-documentdb-collection-rid check and will return back InvalidPartitionException.
@@ -685,7 +685,7 @@ private PartitionKeyRange tryResolveServerPartitionByPartitionKey(
             logger.debug(
                 "Cannot compute effective partition getKey. Definition has '{}' getPaths, values supplied has '{}' getPaths. Will refresh cache and retry.",
                 collection.getPartitionKey().getPaths().size(),
-                partitionKey.getComponents().size());
+                Utils.getCollectionSize(partitionKey.getComponents()));
         }
 
         return null;
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentQueryExecutionContextBase.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentQueryExecutionContextBase.java
index 77df22bd334c..15891694f56d 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentQueryExecutionContextBase.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentQueryExecutionContextBase.java
@@ -171,8 +171,8 @@ public Map createCommonHeadersAsync(FeedOptions feedOptions) {
             requestHeaders.put(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL, desiredConsistencyLevel.toString());
         }
 
-        if(feedOptions.isPopulateQueryMetrics()){
-            requestHeaders.put(HttpConstants.HttpHeaders.POPULATE_QUERY_METRICS, String.valueOf(feedOptions.isPopulateQueryMetrics()));
+        if(feedOptions.isQueryMetricsEnabled()){
+            requestHeaders.put(HttpConstants.HttpHeaders.POPULATE_QUERY_METRICS, String.valueOf(feedOptions.isQueryMetricsEnabled()));
         }
 
         return requestHeaders;
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/routing/PartitionKeyInternal.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/routing/PartitionKeyInternal.java
index 3c3074a1db94..9f16987eb08b 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/routing/PartitionKeyInternal.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/routing/PartitionKeyInternal.java
@@ -259,11 +259,14 @@ public void serialize(PartitionKeyInternal partitionKey, JsonGenerator writer, S
                     return;
                 }
 
-                writer.writeStartArray();
-                for (IPartitionKeyComponent componentValue : partitionKey.getComponents()) {
-                    componentValue.jsonEncode(writer);
+                //  PartitionKey.None has null components - which returns a null list
+                if (partitionKey.getComponents() != null) {
+                    writer.writeStartArray();
+                    for (IPartitionKeyComponent componentValue : partitionKey.getComponents()) {
+                        componentValue.jsonEncode(writer);
+                    }
+                    writer.writeEndArray();
                 }
-                writer.writeEndArray();
             } catch (IOException e) {
                 throw new IllegalStateException(e);
             }
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosAsyncConflictResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosAsyncConflictResponse.java
index 4c03586cdd15..0914d2c6dd22 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosAsyncConflictResponse.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosAsyncConflictResponse.java
@@ -49,6 +49,6 @@ public CosmosAsyncConflict getConflict() {
      * @return the conflict properties
      */
     public CosmosConflictProperties getProperties() {
-        return this.getProperties();
+        return super.getProperties();
     }
 }
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictProperties.java
index 854ac01a8374..4a2bb02683dc 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictProperties.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictProperties.java
@@ -46,8 +46,8 @@ public String getOperationKind() {
      *
      * @return the resource type.
      */
-    public String getResourceType() {
-        return this.conflict.getResouceType();
+    String getResourceType() {
+        return this.conflict.getResourceType();
     }
 
     Resource getResource() {
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java
index cb46a1778e99..09986beca058 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java
@@ -9,7 +9,7 @@
  * Encapsulates options that can be specified for a request issued to Cosmos container.
  */
 public final class CosmosContainerRequestOptions {
-    private boolean populateQuotaInfo;
+    private boolean quotaInfoEnabled;
     private ConsistencyLevel consistencyLevel;
     private String sessionToken;
     private String ifMatchETag;
@@ -17,26 +17,26 @@ public final class CosmosContainerRequestOptions {
     private ThroughputProperties throughputProperties;
 
     /**
-     * Gets the PopulateQuotaInfo setting for cosmos container read requests in the Azure Cosmos DB database service.
-     * PopulateQuotaInfo is used to enable/disable getting cosmos container quota related stats for document
+     * Gets the quotaInfoEnabled setting for cosmos container read requests in the Azure Cosmos DB database service.
+     * quotaInfoEnabled is used to enable/disable getting cosmos container quota related stats for document
      * collection read requests.
      *
-     * @return true if PopulateQuotaInfo is enabled
+     * @return true if quotaInfoEnabled is enabled
      */
-    public boolean isQuotaInfoPopulated() {
-        return populateQuotaInfo;
+    public boolean isQuotaInfoEnabled() {
+        return quotaInfoEnabled;
     }
 
     /**
-     * Sets the PopulateQuotaInfo setting for cosmos container read requests in the Azure Cosmos DB database service.
-     * PopulateQuotaInfo is used to enable/disable getting cosmos container quota related stats for document
+     * Sets the quotaInfoEnabled setting for cosmos container read requests in the Azure Cosmos DB database service.
+     * quotaInfoEnabled is used to enable/disable getting cosmos container quota related stats for document
      * collection read requests.
      *
-     * @param populateQuotaInfo a boolean value indicating whether PopulateQuotaInfo is enabled or not
+     * @param quotaInfoEnabled a boolean value indicating whether quotaInfoEnabled is enabled or not
      * @return the current request options
      */
-    public CosmosContainerRequestOptions setQuotaInfoPopulated(boolean populateQuotaInfo) {
-        this.populateQuotaInfo = populateQuotaInfo;
+    public CosmosContainerRequestOptions setQuotaInfoEnabled(boolean quotaInfoEnabled) {
+        this.quotaInfoEnabled = quotaInfoEnabled;
         return this;
     }
 
@@ -129,7 +129,7 @@ RequestOptions toRequestOptions() {
         RequestOptions options = new RequestOptions();
         options.setIfMatchETag(getIfMatchETag());
         options.setIfNoneMatchETag(getIfNoneMatchETag());
-        options.setPopulateQuotaInfo(populateQuotaInfo);
+        options.setQuotaInfoEnabled(quotaInfoEnabled);
         options.setSessionToken(sessionToken);
         options.setConsistencyLevel(consistencyLevel);
         options.setThroughputProperties(this.throughputProperties);
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/FeedOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/FeedOptions.java
index f88ed2799f67..6ea51eb9b1a9 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/FeedOptions.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/FeedOptions.java
@@ -20,7 +20,7 @@ public final class FeedOptions {
     private Integer maxItemCount;
     private String requestContinuation;
     private PartitionKey partitionkey;
-    private boolean populateQueryMetrics;
+    private boolean queryMetricsEnabled;
     private Map properties;
     private boolean emptyPagesAllowed;
 
@@ -46,7 +46,7 @@ public FeedOptions(FeedOptions options) {
         this.maxItemCount = options.maxItemCount;
         this.requestContinuation = options.requestContinuation;
         this.partitionkey = options.partitionkey;
-        this.populateQueryMetrics = options.populateQueryMetrics;
+        this.queryMetricsEnabled = options.queryMetricsEnabled;
         this.emptyPagesAllowed = options.emptyPagesAllowed;
     }
 
@@ -288,18 +288,18 @@ public FeedOptions setPartitionKey(PartitionKey partitionkey) {
      *
      * @return whether to enable populate query metrics
      */
-    public boolean isPopulateQueryMetrics() {
-        return populateQueryMetrics;
+    public boolean isQueryMetricsEnabled() {
+        return queryMetricsEnabled;
     }
 
     /**
      * Sets the option to enable/disable getting metrics relating to query execution on document query requests
      *
-     * @param populateQueryMetrics whether to enable or disable query metrics
+     * @param queryMetricsEnabled whether to enable or disable query metrics
      * @return the FeedOptionsBase.
      */
-    public FeedOptions setPopulateQueryMetrics(boolean populateQueryMetrics) {
-        this.populateQueryMetrics = populateQueryMetrics;
+    public FeedOptions setQueryMetricsEnabled(boolean queryMetricsEnabled) {
+        this.queryMetricsEnabled = queryMetricsEnabled;
         return this;
     }
 
diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/ConflictTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/ConflictTests.java
index d3f06b9a41bc..b317740fef14 100644
--- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/ConflictTests.java
+++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/ConflictTests.java
@@ -5,7 +5,6 @@
 
 import com.azure.cosmos.implementation.Conflict;
 import com.azure.cosmos.implementation.Document;
-import com.azure.cosmos.models.ModelBridgeInternal;
 import org.apache.commons.io.IOUtils;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -37,7 +36,7 @@ public void getOperationKind() {
     @Test(groups = { "unit" })
     public void getResourceType() {
         Conflict conf = new Conflict(conflictAsString);
-        assertThat(conf.getResouceType()).isEqualTo("document");
+        assertThat(conf.getResourceType()).isEqualTo("document");
         conf.getSourceResourceId();
     }
 
diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/directconnectivity/PartitionKeyInternalTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/directconnectivity/PartitionKeyInternalTest.java
index 36532de98459..a2ba04c389a2 100644
--- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/directconnectivity/PartitionKeyInternalTest.java
+++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/directconnectivity/PartitionKeyInternalTest.java
@@ -3,6 +3,8 @@
 
 package com.azure.cosmos.implementation.directconnectivity;
 
+import com.azure.cosmos.implementation.Utils;
+import com.azure.cosmos.models.PartitionKey;
 import com.azure.cosmos.models.PartitionKeyDefinition;
 import com.azure.cosmos.models.PartitionKeyDefinitionVersion;
 import com.azure.cosmos.models.PartitionKind;
@@ -415,6 +417,12 @@ public void managedNativeCompatibility() {
         verifyEffectivePartitionKeyEncoding(nonLatin, 101, "0B6D25D07748AB9CA0F523D4BAD146C8", true);
     }
 
+    @Test(groups = "unit")
+    private void serializeNonePartitionKey() {
+        String nonePartitionKey = PartitionKey.NONE.toString();
+        assertThat(nonePartitionKey).isEqualTo("");
+    }
+
     private static void validateEffectivePartitionKeyV2(String partitionKeyRangeJson, String expectedHexEncoding) {
         PartitionKeyInternal partitionKey = PartitionKeyInternal.fromJsonString(partitionKeyRangeJson);
 
@@ -422,7 +430,7 @@ private static void validateEffectivePartitionKeyV2(String partitionKeyRangeJson
         partitionKeyDefinition.setKind(PartitionKind.HASH);
         partitionKeyDefinition.setVersion(PartitionKeyDefinitionVersion.V2);
         ArrayList paths = new ArrayList();
-        for (int i = 0; i < partitionKey.getComponents().size(); i++) {
+        for (int i = 0; i < Utils.getCollectionSize(partitionKey.getComponents()); i++) {
             paths.add("/path" + i);
         }
 
diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/AggregateQueryTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/AggregateQueryTests.java
index 4c30a1f92d63..6e2b70c6a417 100644
--- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/AggregateQueryTests.java
+++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/AggregateQueryTests.java
@@ -73,7 +73,7 @@ public void queryDocumentsWithAggregates(boolean qmEnabled) throws Exception {
 
         FeedOptions options = new FeedOptions();
 
-        options.setPopulateQueryMetrics(qmEnabled);
+        options.setQueryMetricsEnabled(qmEnabled);
         options.setMaxDegreeOfParallelism(2);
 
         for (QueryConfig queryConfig : queryConfigs) {
diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/DistinctQueryTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/DistinctQueryTests.java
index de41a87b80d4..85eb05b92c0f 100644
--- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/DistinctQueryTests.java
+++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/DistinctQueryTests.java
@@ -80,7 +80,7 @@ private static int getRandomAge(Random rand) {
     public void queryDocuments(boolean qmEnabled) {
         String query = "SELECT DISTINCT c.name from c";
         FeedOptions options = new FeedOptions();
-        options.setPopulateQueryMetrics(qmEnabled);
+        options.setQueryMetricsEnabled(qmEnabled);
         options.setMaxDegreeOfParallelism(2);
         CosmosPagedFlux queryObservable =
             createdCollection.queryItems(query,
@@ -249,7 +249,7 @@ public void queryDistinctDocuments() {
     public void queryDocumentsForDistinctIntValues(boolean qmEnabled) {
         String query = "SELECT DISTINCT c.intprop from c";
         FeedOptions options = new FeedOptions();
-        options.setPopulateQueryMetrics(qmEnabled);
+        options.setQueryMetricsEnabled(qmEnabled);
         options.setMaxDegreeOfParallelism(2);
         CosmosPagedFlux queryObservable = createdCollection.queryItems(query, options,
                                                                                              CosmosItemProperties.class);
diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OffsetLimitQueryTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OffsetLimitQueryTests.java
index 468a606ef993..a376aced3fe2 100644
--- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OffsetLimitQueryTests.java
+++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OffsetLimitQueryTests.java
@@ -54,7 +54,7 @@ public void queryDocuments(boolean qmEnabled) {
         int takeCount = 10;
         String query = "SELECT * from c OFFSET " + skipCount + " LIMIT " + takeCount;
         FeedOptions options = new FeedOptions();
-        options.setPopulateQueryMetrics(qmEnabled);
+        options.setQueryMetricsEnabled(qmEnabled);
         options.setMaxDegreeOfParallelism(2);
         CosmosPagedFlux queryObservable = createdCollection.queryItems(query, options,
                                                                                                 CosmosItemProperties.class);
diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OrderbyDocumentQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OrderbyDocumentQueryTest.java
index dc4def37dbd4..93811f1b7b82 100644
--- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OrderbyDocumentQueryTest.java
+++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OrderbyDocumentQueryTest.java
@@ -75,7 +75,7 @@ public void queryDocumentsValidateContent(boolean qmEnabled) throws Exception {
             , ModelBridgeInternal.getStringFromJsonSerializable(expectedDocument,"propStr"));
 
         FeedOptions options = new FeedOptions();
-        options.setPopulateQueryMetrics(qmEnabled);
+        options.setQueryMetricsEnabled(qmEnabled);
 
         CosmosPagedFlux queryObservable = createdCollection.queryItems(query, options, CosmosItemProperties.class);
 
diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/ParallelDocumentQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/ParallelDocumentQueryTest.java
index 29f06cb70eaa..2018e73e80d9 100644
--- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/ParallelDocumentQueryTest.java
+++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/ParallelDocumentQueryTest.java
@@ -81,7 +81,7 @@ public void queryDocuments(boolean qmEnabled) {
         String query = "SELECT * from c where c.prop = 99";
         FeedOptions options = new FeedOptions();
 
-        options.setPopulateQueryMetrics(qmEnabled);
+        options.setQueryMetricsEnabled(qmEnabled);
         options.setMaxDegreeOfParallelism(2);
         CosmosPagedFlux queryObservable = createdCollection.queryItems(query, options, CosmosItemProperties.class);
 
@@ -104,7 +104,7 @@ public void queryMetricEquality() throws Exception {
         String query = "SELECT * from c where c.prop = 99";
         FeedOptions options = new FeedOptions();
 
-        options.setPopulateQueryMetrics(true);
+        options.setQueryMetricsEnabled(true);
         options.setMaxDegreeOfParallelism(0);
 
         CosmosPagedFlux queryObservable = createdCollection.queryItems(query, options, CosmosItemProperties.class);
diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/SinglePartitionDocumentQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/SinglePartitionDocumentQueryTest.java
index 8083015e7f2d..0449847d336e 100644
--- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/SinglePartitionDocumentQueryTest.java
+++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/SinglePartitionDocumentQueryTest.java
@@ -60,7 +60,7 @@ public void queryDocuments(boolean queryMetricsEnabled) throws Exception {
         FeedOptions options = new FeedOptions();
         int maxItemCount = 5;
 
-        options.setPopulateQueryMetrics(queryMetricsEnabled);
+        options.setQueryMetricsEnabled(queryMetricsEnabled);
         CosmosPagedFlux queryObservable = createdCollection.queryItems(query, options, CosmosItemProperties.class);
 
         List expectedDocs = createdDocuments.stream().filter(d -> 99 == ModelBridgeInternal.getIntFromJsonSerializable(d,"prop") ).collect(Collectors.toList());
diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/TopQueryTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/TopQueryTests.java
index 9edb44c52f19..593b622c2c80 100644
--- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/TopQueryTests.java
+++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/TopQueryTests.java
@@ -51,7 +51,7 @@ public void queryDocumentsWithTop(boolean qmEnabled) throws Exception {
 
         FeedOptions options = new FeedOptions();
         options.setMaxDegreeOfParallelism(2);
-        options.setPopulateQueryMetrics(qmEnabled);
+        options.setQueryMetricsEnabled(qmEnabled);
 
         int expectedTotalSize = 20;
         int expectedNumberOfPages = 3;