Skip to content

Conversation

@vaibhavatul47
Copy link

Dispose ServiceBusClient after each test

Copilot AI review requested due to automatic review settings January 22, 2026 06:15
@github-actions github-actions bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Service Bus labels Jan 22, 2026
@github-actions
Copy link

Thank you for your contribution @vaibhavatul47! We will review the pull request and get back to you soon.

@vaibhavatul47 vaibhavatul47 changed the title Atulvaibhav/close clients on each test Dispose ServiceBusClient after each test Jan 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request improves resource management in Service Bus test files by ensuring ServiceBusClient instances are properly disposed after each test using the await using pattern. This change helps prevent resource leaks and follows .NET best practices for IAsyncDisposable objects.

Changes:

  • Added await using to ServiceBusClient instantiations across test files
  • Updated method signatures from void to async Task where needed to support async disposal
  • Applied consistent disposal pattern to both test code and sample/documentation code
  • Ensured CreateNoRetryClient() instances are properly scoped and disposed

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
TransactionLiveTests.cs Wrapped CreateNoRetryClient() in async using block for proper disposal
SenderLiveTests.cs Added await using for ServiceBusClient instances across multiple test methods
Sample16_CrossReceiverMessageSettlement.cs Updated sample code to use await using for ServiceBusClient
Sample14_AMQPMessage.cs Updated sample code to use await using for ServiceBusClient
Sample13_AdvancedConfiguration.cs Changed method signatures to async Task and added await using for clients
Sample11_CloudEvents.cs Wrapped CreateNoRetryClient() in async using block
Sample10_ClaimCheck.cs Updated sample code to use await using for ServiceBusClient
Sample02_MessageSettlement.cs Wrapped CreateNoRetryClient() instances in async using blocks
SessionReceiverLiveTests.cs Wrapped CreateNoRetryClient() in async using block
SessionProcessorLiveTests.cs Wrapped CreateNoRetryClient() instances in async using blocks across multiple tests
ProcessorLiveTests.cs Wrapped CreateNoRetryClient() in async using block
EventSourceLiveTests.cs Added await using for ServiceBusClient instance
DiagnosticScopeLiveTests.cs Added await using for ServiceBusClient instances across multiple tests
DiagnosticScopeActivitySourceLiveTests.cs Added await using for ServiceBusClient instances across multiple tests
ServiceBusClientLiveTests.cs Added await using for ServiceBusClient instances across multiple tests
Sample16_CrossReceiverMessageSettlement.md Updated markdown documentation to show await using pattern
Sample14_AMQPMessage.md Updated markdown documentation to show await using pattern
Sample13_AdvancedConfiguration.md Updated markdown documentation to show await using pattern
Sample10_ClaimCheck.md Updated markdown documentation to show await using pattern

@vaibhavatul47 vaibhavatul47 force-pushed the atulvaibhav/close_clients_on_each_test branch from 72ef30d to 6d6398e Compare January 22, 2026 06:49
Copy link
Member

@jsquire jsquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vaibhavatul47:

Code changes look good, but you'll need to complete onboarding to the repository for this to move forward.

Currently, your account lacks the public membership to the Azure and Microsoft GitHub organizations that require of an internal contributor. You are also missing the required write permission. Please review the Azure SDK onboarding documentation and use the associated Teams channel for support.

You can verify the state of your account by running the Validate-AzsdkCodeOwner script from the Azure SDK tools repository.

Please also be sure to add yourself to CODEOWNERS for this library, if you will be maintaining it going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Service Bus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants