Eat errors in SetupChannel (#52)
* SetupChannel needs to eat its errors. Callers cannot catch exceptions from async void methods.
* PR suggestions.
Co-authored-by: Christopher Bell <christopher.bell@stretto.com>
diff --git a/src/DotPulsar/Internal/ConsumerProcess.cs b/src/DotPulsar/Internal/ConsumerProcess.cs
index 449aedb..a078146 100644
--- a/src/DotPulsar/Internal/ConsumerProcess.cs
+++ b/src/DotPulsar/Internal/ConsumerProcess.cs
@@ -84,8 +84,15 @@
private async void SetupChannel()
{
- var channel = await _factory.Create(CancellationTokenSource.Token).ConfigureAwait(false);
- await _consumer.SetChannel(channel).ConfigureAwait(false);
+ try
+ {
+ var channel = await _factory.Create(CancellationTokenSource.Token).ConfigureAwait(false);
+ await _consumer.SetChannel(channel).ConfigureAwait(false);
+ }
+ catch
+ {
+ // ignored
+ }
}
}
}
diff --git a/src/DotPulsar/Internal/ProducerProcess.cs b/src/DotPulsar/Internal/ProducerProcess.cs
index fad638a..81861e3 100644
--- a/src/DotPulsar/Internal/ProducerProcess.cs
+++ b/src/DotPulsar/Internal/ProducerProcess.cs
@@ -68,8 +68,15 @@
private async void SetupChannel()
{
- var channel = await _factory.Create(CancellationTokenSource.Token).ConfigureAwait(false);
- await _producer.SetChannel(channel).ConfigureAwait(false);
+ try
+ {
+ var channel = await _factory.Create(CancellationTokenSource.Token).ConfigureAwait(false);
+ await _producer.SetChannel(channel).ConfigureAwait(false);
+ }
+ catch
+ {
+ // ignored
+ }
}
}
}
diff --git a/src/DotPulsar/Internal/ReaderProcess.cs b/src/DotPulsar/Internal/ReaderProcess.cs
index 9b9a438..67763c5 100644
--- a/src/DotPulsar/Internal/ReaderProcess.cs
+++ b/src/DotPulsar/Internal/ReaderProcess.cs
@@ -71,8 +71,15 @@
private async void SetupChannel()
{
- var channel = await _factory.Create(CancellationTokenSource.Token).ConfigureAwait(false);
- await _reader.SetChannel(channel).ConfigureAwait(false);
+ try
+ {
+ var channel = await _factory.Create(CancellationTokenSource.Token).ConfigureAwait(false);
+ await _reader.SetChannel(channel).ConfigureAwait(false);
+ }
+ catch
+ {
+ // ignored
+ }
}
}
}