Skip to content

Misc items #1766

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

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion projects/RabbitMQ.Client/Impl/AutorecoveringChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,23 @@ await _connection.DeleteRecordedChannelAsync(this,
public override string ToString()
=> InnerChannel.ToString();

public void Dispose() => DisposeAsync().AsTask().GetAwaiter().GetResult();
public void Dispose()
{
if (_disposed)
{
return;
}

DisposeAsync().AsTask().GetAwaiter().GetResult();
}

public async ValueTask DisposeAsync()
{
if (_disposed)
{
return;
}

if (IsDisposing)
{
return;
Expand Down
15 changes: 14 additions & 1 deletion projects/RabbitMQ.Client/Impl/AutorecoveringConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,23 @@ await RecordChannelAsync(autorecoveringChannel, channelsSemaphoreHeld: false, ca
return autorecoveringChannel;
}

public void Dispose() => DisposeAsync().AsTask().GetAwaiter().GetResult();
public void Dispose()
{
if (_disposed)
{
return;
}

DisposeAsync().AsTask().GetAwaiter().GetResult();
}

public async ValueTask DisposeAsync()
{
if (_disposed)
{
return;
}

if (IsDisposing)
{
return;
Expand Down
18 changes: 17 additions & 1 deletion projects/RabbitMQ.Client/Impl/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ void IDisposable.Dispose()

protected virtual void Dispose(bool disposing)
{
if (_disposed)
{
return;
}

if (IsDisposing)
{
return;
Expand Down Expand Up @@ -559,6 +564,11 @@ protected virtual void Dispose(bool disposing)

public async ValueTask DisposeAsync()
{
if (_disposed)
{
return;
}

await DisposeAsyncCore()
.ConfigureAwait(false);

Expand All @@ -567,6 +577,11 @@ await DisposeAsyncCore()

protected virtual async ValueTask DisposeAsyncCore()
{
if (_disposed)
{
return;
}

if (IsDisposing)
{
return;
Expand All @@ -576,7 +591,8 @@ protected virtual async ValueTask DisposeAsyncCore()
{
if (IsOpen)
{
await this.AbortAsync().ConfigureAwait(false);
await this.AbortAsync()
.ConfigureAwait(false);
}

if (_serverOriginatedChannelCloseTcs is not null)
Expand Down
15 changes: 14 additions & 1 deletion projects/RabbitMQ.Client/Impl/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,23 @@ internal ValueTask WriteAsync(RentedMemory frames, CancellationToken cancellatio
return _frameHandler.WriteAsync(frames, cancellationToken);
}

public void Dispose() => DisposeAsync().AsTask().GetAwaiter().GetResult();
public void Dispose()
{
if (_disposed)
{
return;
}

DisposeAsync().AsTask().GetAwaiter().GetResult();
}

public async ValueTask DisposeAsync()
{
if (_disposed)
{
return;
}

if (IsDisposing)
{
return;
Expand Down
4 changes: 2 additions & 2 deletions projects/Test/Integration/TestQueueDeclare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public async Task TestPassiveQueueDeclareException_GH1749()
{
await _channel.QueueDeclarePassiveAsync(q);
}
catch (Exception ex)
catch (Exception)
{
_output.WriteLine("{0} ex: {1}", _testDisplayName, ex);
// _output.WriteLine("{0} ex: {1}", _testDisplayName, ex);
await _channel.DisposeAsync();
_channel = null;
}
Expand Down
19 changes: 15 additions & 4 deletions projects/Test/Integration/TestToxiproxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,25 @@ public override Task InitializeAsync()
Assert.Null(_conn);
Assert.Null(_channel);

_toxiproxyManager = new ToxiproxyManager(_testDisplayName, IsRunningInCI, IsWindows);
_proxyPort = ToxiproxyManager.ProxyPort;
return _toxiproxyManager.InitializeAsync();
if (AreToxiproxyTestsEnabled)
{
_toxiproxyManager = new ToxiproxyManager(_testDisplayName, IsRunningInCI, IsWindows);
_proxyPort = ToxiproxyManager.ProxyPort;
return _toxiproxyManager.InitializeAsync();
}
else
{
return Task.CompletedTask;
}
}

public override async Task DisposeAsync()
{
await _toxiproxyManager.DisposeAsync();
if (AreToxiproxyTestsEnabled)
{
await _toxiproxyManager.DisposeAsync();
}

await base.DisposeAsync();
}

Expand Down
Loading