Fix bug when disposing a client with multiple consumers, readers or producers and make ready for release 0.7.2
diff --git a/src/DotPulsar/DotPulsar.csproj b/src/DotPulsar/DotPulsar.csproj
index b9c0614..a1eaa44 100644
--- a/src/DotPulsar/DotPulsar.csproj
+++ b/src/DotPulsar/DotPulsar.csproj
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
- <Version>0.7.1</Version>
+ <Version>0.7.2</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
<Authors>DanskeCommodities;dblank</Authors>
@@ -11,7 +11,7 @@
<Title>DotPulsar</Title>
<PackageTags>Apache;Pulsar</PackageTags>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
- <PackageReleaseNotes>Beta release - ConfigureAwait(false) all via Fody.ConfigureAwait</PackageReleaseNotes>
+ <PackageReleaseNotes>Beta release - Fixed possible exception when disposing a client with multiple consumers, readers or producers</PackageReleaseNotes>
<Description>.NET/C# client library for Apache Pulsar</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
diff --git a/src/DotPulsar/PulsarClient.cs b/src/DotPulsar/PulsarClient.cs
index b9490de..fb7d2d3 100644
--- a/src/DotPulsar/PulsarClient.cs
+++ b/src/DotPulsar/PulsarClient.cs
@@ -4,6 +4,7 @@
using DotPulsar.Internal.Abstractions;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
namespace DotPulsar
@@ -65,15 +66,19 @@
public async ValueTask DisposeAsync()
{
+ IAsyncDisposable[] disposables;
+
lock (_lock)
{
if (_isClosed)
return;
_isClosed = true;
+ disposables = _disposabels.ToArray();
}
- foreach (var disposable in _disposabels)
+
+ foreach (var disposable in disposables)
{
await disposable.DisposeAsync();
}