diff --git a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs index 77f0467bdf..2793190908 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs @@ -22,8 +22,6 @@ namespace Microsoft.Azure.Cosmos public class TransactionalBatchResponse : IReadOnlyList, IDisposable #pragma warning restore CA1710 // Identifiers should have correct suffix { - private bool isDisposed; - private List results; /// @@ -198,7 +196,6 @@ virtual IEnumerable GetActivityIds() public void Dispose() { this.Dispose(true); - GC.SuppressFinalize(this); } /// @@ -385,9 +382,8 @@ private static async Task PopulateFromContentAsync( /// Indicates whether to dispose managed resources or not. protected virtual void Dispose(bool disposing) { - if (disposing && !this.isDisposed) + if (disposing) { - this.isDisposed = true; if (this.Operations != null) { foreach (ItemBatchOperation operation in this.Operations) diff --git a/Microsoft.Azure.Cosmos/src/DocumentClient.cs b/Microsoft.Azure.Cosmos/src/DocumentClient.cs index cb7ddc3c80..e9f7417996 100644 --- a/Microsoft.Azure.Cosmos/src/DocumentClient.cs +++ b/Microsoft.Azure.Cosmos/src/DocumentClient.cs @@ -1376,11 +1376,7 @@ public void Dispose() this.storeClientFactory = null; } - if (this.AddressResolver != null) - { - this.AddressResolver.Dispose(); - this.AddressResolver = null; - } + this.AddressResolver = null; if (this.httpClient != null) { diff --git a/Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs b/Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs index 956d1f1902..535ba06e9c 100644 --- a/Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs +++ b/Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs @@ -145,7 +145,6 @@ public virtual async Task GetDatabaseAccountAsync(Func ToPartitionAddressAndRange(string collectionRid, IList
addresses) { Address address = addresses.First(); diff --git a/Microsoft.Azure.Cosmos/src/Routing/GlobalAddressResolver.cs b/Microsoft.Azure.Cosmos/src/Routing/GlobalAddressResolver.cs index 4eab75389b..482e48cd96 100644 --- a/Microsoft.Azure.Cosmos/src/Routing/GlobalAddressResolver.cs +++ b/Microsoft.Azure.Cosmos/src/Routing/GlobalAddressResolver.cs @@ -20,7 +20,7 @@ namespace Microsoft.Azure.Cosmos.Routing /// AddressCache implementation for client SDK. Supports cross region address routing based on /// avaialbility and preference list. ///
- internal sealed class GlobalAddressResolver : IAddressResolver, IDisposable + internal sealed class GlobalAddressResolver : IAddressResolver { private const int MaxBackupReadRegions = 3; @@ -153,14 +153,6 @@ private IAddressResolver GetAddressResolver(DocumentServiceRequest request) return this.GetOrAddEndpoint(endpoint).AddressResolver; } - public void Dispose() - { - foreach (EndpointCache endpointCache in this.addressCacheByEndpoint.Values) - { - endpointCache.AddressCache.Dispose(); - } - } - private EndpointCache GetOrAddEndpoint(Uri endpoint) { // The GetorAdd is followed by a call to .Count which in a ConcurrentDictionary diff --git a/Microsoft.Azure.Cosmos/src/SecureStringHMACSHA256Helper.cs b/Microsoft.Azure.Cosmos/src/SecureStringHMACSHA256Helper.cs index 400fbf3300..3106b4b6bb 100644 --- a/Microsoft.Azure.Cosmos/src/SecureStringHMACSHA256Helper.cs +++ b/Microsoft.Azure.Cosmos/src/SecureStringHMACSHA256Helper.cs @@ -53,20 +53,19 @@ public void Dispose() GC.SuppressFinalize(this); } + ~SecureStringHMACSHA256Helper() => this.Dispose(false); + private void Dispose(bool disposing) { - if (disposing) + if (this.algorithmHandle != IntPtr.Zero) { - if (this.algorithmHandle != null) + int status = NativeMethods.BCryptCloseAlgorithmProvider(this.algorithmHandle, 0); + if (status != 0) { - int status = NativeMethods.BCryptCloseAlgorithmProvider(this.algorithmHandle, 0); - if (status != 0) - { - DefaultTrace.TraceError("Failed to close algorithm provider: {0}", status); - } - - this.algorithmHandle = IntPtr.Zero; + DefaultTrace.TraceError("Failed to close algorithm provider: {0}", status); } + + this.algorithmHandle = IntPtr.Zero; } } diff --git a/Microsoft.Azure.Cosmos/src/SessionContainer.cs b/Microsoft.Azure.Cosmos/src/SessionContainer.cs index 771d5808b7..cf7dcefccb 100644 --- a/Microsoft.Azure.Cosmos/src/SessionContainer.cs +++ b/Microsoft.Azure.Cosmos/src/SessionContainer.cs @@ -472,14 +472,6 @@ public SessionContainerState(string hostName) { this.hostName = hostName; } - - ~SessionContainerState() - { - if (this.rwlock != null) - { - this.rwlock.Dispose(); - } - } } private sealed class SessionContainerSnapshot