Skip to content
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

Disposing Asynchronously #434

Merged
merged 30 commits into from
Aug 17, 2023
Merged

Disposing Asynchronously #434

merged 30 commits into from
Aug 17, 2023

Conversation

sburmanoctopus
Copy link
Contributor

@sburmanoctopus sburmanoctopus commented Aug 16, 2023

[sc-53211]

Background

As part of making Halibut async, we need to ensure we dispose of things asynchronously as well.

Results

Related to OctopusDeploy/Issues#8266

Before

The following places were found to have paths that would require async disposal. These were being disposed synchronously.

After

The green classes in the spreadsheet are not disposed asynchronously.

We did not change using statements to `await using' statements in this PR. This touched over 20 files, so will be assessed and implemented in a different PR.

To ensure .NET 4.8 code could compile and use IAsyncDisposable, we had to import the Microsoft.Bcl.AsyncInterfaces package.

How to review this PR

Quality ✔️

Pre-requisites

  • I have read How we use GitHub Issues for help deciding when and where it's appropriate to make an issue.
  • I have considered informing or consulting the right people, according to the ownership map.
  • I have considered appropriate testing for my change.

# Conflicts:
#	source/Halibut.Tests/Transport/ConnectionManagerFixture.cs
# Conflicts:
#	source/Halibut.Tests/Transport/ConnectionPoolFixture.cs
#	source/Halibut/Transport/ConnectionManager.cs
#	source/Halibut/Transport/ConnectionPool.cs
# Conflicts:
#	source/Halibut.Tests/Support/TestConnection.cs
#	source/Halibut.Tests/Transport/ConnectionPoolFixture.cs
#	source/Halibut/HalibutRuntime.cs
#	source/Halibut/Transport/ConnectionManager.cs
#	source/Halibut/Transport/ConnectionManagerAsync.cs
#	source/Halibut/Transport/ConnectionPool.cs
#	source/Halibut/Transport/ConnectionPoolAsync.cs
#	source/Halibut/Transport/IConnectionManager.cs
#	source/Halibut/Transport/IConnectionPool.cs
#	source/Halibut/Transport/SecureClient.cs
#	source/Halibut/Transport/SecureListeningClient.cs
#	source/Halibut/Transport/SecureWebSocketClient.cs
@shortcut-integration
Copy link

# Conflicts:
#	source/Halibut/ServiceModel/PendingRequestQueueAsync.cs
#	source/Halibut/Transport/SecureConnection.cs
@sburmanoctopus sburmanoctopus changed the title Sast/ssl async fix Disposing Asynchronously Aug 16, 2023
@sburmanoctopus sburmanoctopus marked this pull request as ready for review August 16, 2023 07:11
@sburmanoctopus sburmanoctopus requested a review from a team as a code owner August 16, 2023 07:11
Copy link
Contributor

@acodrington acodrington left a comment

Choose a reason for hiding this comment

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

Yeah looks good dude, nice one!

public abstract class AsyncDisposableStream : Stream
#if NETFRAMEWORK
, IAsyncDisposable
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Truly, truly awful 😆

It's good we're keeping this hidden

@@ -99,7 +119,7 @@ public async Task<IConnection> AcquireConnectionAsync(ExchangeProtocolBuilder ex
Tuple<IConnection, Action> CreateNewConnection(ExchangeProtocolBuilder exchangeProtocolBuilder, IConnectionFactory connectionFactory, ServiceEndPoint serviceEndpoint, ILog log, CancellationToken cancellationToken)
{
var lazyConnection = new Lazy<IConnection>(() => connectionFactory.EstablishNewConnection(exchangeProtocolBuilder, serviceEndpoint, log, cancellationToken));
var connection = new DisposableNotifierConnection(lazyConnection, OnConnectionDisposed);
var connection = new DisposableNotifierConnection(lazyConnection, OnConnectionDisposed, OnConnectionDisposedAsync);
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: This sync implementation is slated for removal for the context of other readers.

Copy link
Contributor

@nathanwoctopusdeploy nathanwoctopusdeploy left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@sburmanoctopus sburmanoctopus merged commit 66b1c3e into main Aug 17, 2023
10 of 14 checks passed
@sburmanoctopus sburmanoctopus deleted the sast/SSLAsyncFix branch August 17, 2023 02:02
@sburmanoctopus sburmanoctopus mentioned this pull request Aug 17, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants