Skip to content

Commit

Permalink
Updated exception checks and maxWorkerTasks check to ensure tests pas…
Browse files Browse the repository at this point in the history
…s and verify all scenarios
  • Loading branch information
phillip-haydon committed Aug 15, 2024
1 parent d373975 commit 2435703
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ private void CreateWorkerTask()
/// </summary>
private int CalculateDesiredWorkers(int queueSize)
{
if (queueSize == 0)
// Should never have a _maxWorkerTasks of 0, but there's a couple of unit tests
// which use 0 to determine if messages are discarded when the queue is full
// so we need to allow for 0 workers to verify those tests.
if (queueSize == 0 || _maxWorkerTasks == 0)
{
return 0;
}
Expand Down Expand Up @@ -201,7 +204,9 @@ private static async Task RaygunMessageWorker(BlockingCollection<Func<Task<Raygu
await callback(message, cancellationToken);
}
}
catch (OperationCanceledException)
catch (Exception cancelledEx) when (cancelledEx is ThreadAbortException
or OperationCanceledException
or TaskCanceledException)
{
// Task was cancelled, this is expected behavior
}
Expand Down

0 comments on commit 2435703

Please sign in to comment.