Skip to content

Commit

Permalink
- Don't dispose of client via service due to shared reference (servic…
Browse files Browse the repository at this point in the history
…e can be diposed of via client)
  • Loading branch information
nwithan8 committed Sep 17, 2024
1 parent c07e131 commit 0aa9bf4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion EasyPost.Tests/ServicesTests/ServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void TestServiceDisposal()
Client client = new(new ClientConfiguration("not_a_real_api_key"));

AddressService addressService = client.Address;
addressService.Dispose(); // Will also dispose the underlying client
addressService.Dispose();

// As long as this test doesn't throw an exception, it passes
}
Expand Down
4 changes: 2 additions & 2 deletions EasyPost/_base/EasyPostService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ protected virtual void Dispose(bool disposing)

// Dispose managed state (managed objects)

// Attempt to dispose the client (may already be disposed)
Client.Dispose();
// Don't dispose of the associated client here, as it may be shared among multiple services
// Client.Dispose();
}

/// <summary>
Expand Down

0 comments on commit 0aa9bf4

Please sign in to comment.