-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Dispose ServiceBusClient after each test #55182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Dispose ServiceBusClient after each test #55182
Conversation
|
Thank you for your contribution @vaibhavatul47! We will review the pull request and get back to you soon. |
There was a problem hiding this 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 usingtoServiceBusClientinstantiations across test files - Updated method signatures from
voidtoasync Taskwhere 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 |
sdk/servicebus/Azure.Messaging.ServiceBus/tests/Sender/SenderLiveTests.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/tests/Sender/SenderLiveTests.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/tests/Samples/Sample11_CloudEvents.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/tests/Samples/Sample02_MessageSettlement.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/tests/Samples/Sample02_MessageSettlement.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/tests/Samples/Sample02_MessageSettlement.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/tests/Processor/ProcessorLiveTests.cs
Outdated
Show resolved
Hide resolved
72ef30d to
6d6398e
Compare
jsquire
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
- Azure SDK onboarding (Microsoft internal)
- Azure SDK onboarding assistance (Microsoft internal)
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.
Dispose ServiceBusClient after each test