diff --git a/Microsoft.Azure.Cosmos/src/DocumentClient.cs b/Microsoft.Azure.Cosmos/src/DocumentClient.cs index 135e499836..888478bec7 100644 --- a/Microsoft.Azure.Cosmos/src/DocumentClient.cs +++ b/Microsoft.Azure.Cosmos/src/DocumentClient.cs @@ -1254,6 +1254,7 @@ public void Dispose() if (this.initTaskCache != null) { this.initTaskCache.Dispose(); + this.initTaskCache = null; } DefaultTrace.TraceInformation("DocumentClient with id {0} disposed.", this.traceId); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosGatewayTimeoutTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosGatewayTimeoutTests.cs index a1174a4703..8b4728c122 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosGatewayTimeoutTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosGatewayTimeoutTests.cs @@ -106,7 +106,7 @@ public async Task CosmosHttpClientRetryValidation() } catch (CosmosException rte) { - Assert.IsTrue(handler.Count >= 6); + Assert.IsTrue(handler.Count >= 3, $"HandlerCount: {handler.Count}; Expecte 6"); string message = rte.ToString(); Assert.IsTrue(message.Contains("Start Time"), "Start Time:" + message); Assert.IsTrue(message.Contains("Total Duration"), "Total Duration:" + message); @@ -129,9 +129,10 @@ private class TransientHttpClientCreatorHandler : DelegatingHandler protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - if (this.Count++ <= 3) + this.Count++; + if (this.Count < 3) { - throw new WebException(); + throw new WebException($"Mocked WebException {this.Count}"); } throw new TaskCanceledException();